diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/Elastic.Clients.Elasticsearch.Serverless.csproj b/src/Elastic.Clients.Elasticsearch.Serverless/Elastic.Clients.Elasticsearch.Serverless.csproj index 8ba54c7ca36..c3273d3eb74 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/Elastic.Clients.Elasticsearch.Serverless.csproj +++ b/src/Elastic.Clients.Elasticsearch.Serverless/Elastic.Clients.Elasticsearch.Serverless.csproj @@ -19,9 +19,14 @@ true true annotations + true + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs index ac935fb70ef..7a585979fc3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs @@ -18,14 +18,161 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.AsyncSearch; +internal sealed partial class AsyncSearchStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override AsyncSearchStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusters = default; + LocalJsonProperty propCompletionStatus = default; + LocalJsonProperty propCompletionTime = default; + LocalJsonProperty propCompletionTimeInMillis = default; + LocalJsonProperty propExpirationTime = default; + LocalJsonProperty propExpirationTimeInMillis = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propStartTime = default; + LocalJsonProperty propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AsyncSearchStatusResponse + { + Clusters = propClusters.Value +, + CompletionStatus = propCompletionStatus.Value +, + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Shards = propShards.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AsyncSearchStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AsyncSearchStatusResponseConverter))] public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse { /// @@ -34,7 +181,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Not shown for local-only searches. /// /// - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.Serverless.ClusterStatistics? Clusters { get; init; } /// @@ -44,7 +190,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// 503 indicates that the async search was completed with an error. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -53,9 +198,7 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -63,11 +206,8 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -76,7 +216,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -85,7 +224,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -93,10 +231,7 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Indicates how many shards have run the query so far. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs index 66a78fb63cb..f9853190696 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.AsyncSearch; +internal sealed partial class DeleteAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAsyncSearchResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncSearchResponseConverter))] public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs index a7fd20fd67d..1e8cf4d10f0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs @@ -18,14 +18,158 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.AsyncSearch; +internal sealed partial class GetAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompletionTime = default; + LocalJsonProperty propCompletionTimeInMillis = default; + LocalJsonProperty propExpirationTime = default; + LocalJsonProperty propExpirationTimeInMillis = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty> propResponse = default; + LocalJsonProperty propStartTime = default; + LocalJsonProperty propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propResponse.TryRead(ref reader, options, PropResponse)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncSearchResponse + { + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Response = propResponse.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropResponse, value.Response); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetAsyncSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetAsyncSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetAsyncSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetAsyncSearchResponseConverterFactory))] public sealed partial class GetAsyncSearchResponse : ElasticsearchResponse { /// @@ -34,9 +178,7 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -44,11 +186,8 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -57,7 +196,6 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -66,12 +204,8 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } - [JsonInclude, JsonPropertyName("response")] public Elastic.Clients.Elasticsearch.Serverless.AsyncSearch.AsyncSearch Response { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs index da346fb535f..d3199154d1a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -231,410 +232,346 @@ public sealed partial class SubmitAsyncSearchRequestParameters : RequestParamete public Elastic.Clients.Elasticsearch.Serverless.Duration? WaitForCompletionTimeout { get => Q("wait_for_completion_timeout"); set => Q("wait_for_completion_timeout", value); } } -internal sealed partial class SubmitAsyncSearchRequestConverter : JsonConverter +internal sealed partial class SubmitAsyncSearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override SubmitAsyncSearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SubmitAsyncSearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SubmitAsyncSearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propCollapse = default; + LocalJsonProperty?> propDocvalueFields = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty?> propExt = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty>?> propIndicesBoost = default; + LocalJsonProperty?> propKnn = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propPit = default; + LocalJsonProperty propPostFilter = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propRescore = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSeqNoPrimaryTerm = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propSlice = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty?> propStats = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propSuggest = default; + LocalJsonProperty propTerminateAfter = default; + LocalJsonProperty propTimeout = default; + LocalJsonProperty propTrackScores = default; + LocalJsonProperty propTrackTotalHits = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slice") - { - variant.Slice = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, SubmitAsyncSearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SubmitAsyncSearchRequest + { + Aggregations = propAggregations.Value + , + Collapse = propCollapse.Value + , + DocvalueFields = propDocvalueFields.Value + , + Explain = propExplain.Value + , + Ext = propExt.Value + , + Fields = propFields.Value + , + From = propFrom.Value + , + Highlight = propHighlight.Value + , + IndicesBoost = propIndicesBoost.Value + , + Knn = propKnn.Value + , + MinScore = propMinScore.Value + , + Pit = propPit.Value + , + PostFilter = propPostFilter.Value + , + Profile = propProfile.Value + , + Query = propQuery.Value + , + Rescore = propRescore.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + SearchAfter = propSearchAfter.Value + , + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value + , + Size = propSize.Value + , + Slice = propSlice.Value + , + Sort = propSort.Value + , + Source = propSource.Value + , + Stats = propStats.Value + , + StoredFields = propStoredFields.Value + , + Suggest = propSuggest.Value + , + TerminateAfter = propTerminateAfter.Value + , + Timeout = propTimeout.Value + , + TrackScores = propTrackScores.Value + , + TrackTotalHits = propTrackTotalHits.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SubmitAsyncSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRescore, value.Rescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } @@ -678,7 +615,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -686,7 +622,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Indicate if an error should be returned if there is a partial search failure or timeout /// /// - [JsonIgnore] public bool? AllowPartialSearchResults { get => Q("allow_partial_search_results"); set => Q("allow_partial_search_results", value); } /// @@ -694,7 +629,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The analyzer to use for the query string /// /// - [JsonIgnore] public string? Analyzer { get => Q("analyzer"); set => Q("analyzer", value); } /// @@ -702,7 +636,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify whether wildcard and prefix queries should be analyzed (default: false) /// /// - [JsonIgnore] public bool? AnalyzeWildcard { get => Q("analyze_wildcard"); set => Q("analyze_wildcard", value); } /// @@ -711,7 +644,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default). /// /// - [JsonIgnore] public long? BatchedReduceSize { get => Q("batched_reduce_size"); set => Q("batched_reduce_size", value); } /// @@ -719,7 +651,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The default value is the only supported value. /// /// - [JsonIgnore] public bool? CcsMinimizeRoundtrips { get => Q("ccs_minimize_roundtrips"); set => Q("ccs_minimize_roundtrips", value); } /// @@ -727,7 +658,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The default operator for query string query (AND or OR) /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -735,7 +665,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The field to use as default where no field prefix is given in the query string /// /// - [JsonIgnore] public string? Df { get => Q("df"); set => Q("df", value); } /// @@ -743,7 +672,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Whether to expand wildcard expression to concrete indices that are open, closed or both. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -751,7 +679,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Whether specified concrete, expanded or aliased indices should be ignored when throttled /// /// - [JsonIgnore] public bool? IgnoreThrottled { get => Q("ignore_throttled"); set => Q("ignore_throttled", value); } /// @@ -759,7 +686,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Whether specified concrete indices should be ignored when unavailable (missing or closed) /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -767,7 +693,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// If true, results are stored for later retrieval when the search completes within the wait_for_completion_timeout. /// /// - [JsonIgnore] public bool? KeepOnCompletion { get => Q("keep_on_completion"); set => Q("keep_on_completion", value); } /// @@ -775,7 +700,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify whether format-based query failures (such as providing text to a numeric field) should be ignored /// /// - [JsonIgnore] public bool? Lenient { get => Q("lenient"); set => Q("lenient", value); } /// @@ -783,7 +707,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests /// /// - [JsonIgnore] public long? MaxConcurrentShardRequests { get => Q("max_concurrent_shard_requests"); set => Q("max_concurrent_shard_requests", value); } /// @@ -791,7 +714,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify the node or shard the operation should be performed on (default: random) /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -799,7 +721,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Query in the Lucene query string syntax /// /// - [JsonIgnore] public string? QueryLuceneSyntax { get => Q("q"); set => Q("q", value); } /// @@ -807,7 +728,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify if request cache should be used for this request or not, defaults to true /// /// - [JsonIgnore] public bool? RequestCache { get => Q("request_cache"); set => Q("request_cache", value); } /// @@ -815,7 +735,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Indicates whether hits.total should be rendered as an integer or an object in the rest search response /// /// - [JsonIgnore] public bool? RestTotalHitsAsInt { get => Q("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); } /// @@ -823,7 +742,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// A comma-separated list of specific routing values /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -831,7 +749,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Search operation type /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -839,7 +756,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// A list of fields to exclude from the returned _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -847,7 +763,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// A list of fields to extract and return from the _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -855,7 +770,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -863,7 +777,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify suggest mode /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -871,7 +784,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// How many suggestions to return in response /// /// - [JsonIgnore] public long? SuggestSize { get => Q("suggest_size"); set => Q("suggest_size", value); } /// @@ -879,7 +791,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// The source text for which the suggestions should be returned. /// /// - [JsonIgnore] public string? SuggestText { get => Q("suggest_text"); set => Q("suggest_text", value); } /// @@ -887,7 +798,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Specify whether aggregation and suggester names should be prefixed by their respective types in the response /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -896,11 +806,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// When the async search completes within the timeout, the response won’t include the ID as the results are not stored in the cluster. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? WaitForCompletionTimeout { get => Q("wait_for_completion_timeout"); set => Q("wait_for_completion_timeout", value); } - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -909,7 +816,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -917,7 +823,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -925,7 +830,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -934,7 +838,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -944,9 +847,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; set; } /// @@ -954,7 +855,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -962,8 +862,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -972,7 +870,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -981,11 +878,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? Pit { get; set; } - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilter { get; set; } - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -993,10 +887,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("rescore")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1005,7 +896,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1013,9 +903,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Retrieve a script evaluation (based on different fields) for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -1024,7 +912,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// of each hit. See Optimistic concurrency control. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -1034,12 +921,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.Serverless.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1048,7 +931,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// @@ -1058,7 +940,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1069,10 +950,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// and stored fields in the search response. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? Suggest { get; set; } /// @@ -1082,7 +960,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// before sorting. Defaults to 0, which does not terminate query execution early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1092,7 +969,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1100,7 +976,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// If true, calculate and return document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -1111,7 +986,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// Defaults to 10,000 hits. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1119,7 +993,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs index 2aa8d3f0afe..776b863bd4b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs @@ -18,14 +18,158 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.AsyncSearch; +internal sealed partial class SubmitAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override SubmitAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompletionTime = default; + LocalJsonProperty propCompletionTimeInMillis = default; + LocalJsonProperty propExpirationTime = default; + LocalJsonProperty propExpirationTimeInMillis = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty> propResponse = default; + LocalJsonProperty propStartTime = default; + LocalJsonProperty propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propResponse.TryRead(ref reader, options, PropResponse)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SubmitAsyncSearchResponse + { + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Response = propResponse.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SubmitAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropResponse, value.Response); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +internal sealed partial class SubmitAsyncSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SubmitAsyncSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SubmitAsyncSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SubmitAsyncSearchResponseConverterFactory))] public sealed partial class SubmitAsyncSearchResponse : ElasticsearchResponse { /// @@ -34,9 +178,7 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -44,11 +186,8 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -57,7 +196,6 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -66,12 +204,8 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } - [JsonInclude, JsonPropertyName("response")] public Elastic.Clients.Elasticsearch.Serverless.AsyncSearch.AsyncSearch Response { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/BulkResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/BulkResponse.g.cs index 6540f2c9a6c..47b7600bf46 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/BulkResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/BulkResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class BulkResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropIngestTook = System.Text.Json.JsonEncodedText.Encode("ingest_took"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override BulkResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propErrors = default; + LocalJsonProperty propIngestTook = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propIngestTook.TryRead(ref reader, options, PropIngestTook)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkResponse + { + Errors = propErrors.Value +, + IngestTook = propIngestTook.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropIngestTook, value.IngestTook); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkResponseConverter))] public sealed partial class BulkResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("errors")] public bool Errors { get; init; } - [JsonInclude, JsonPropertyName("ingest_took")] public long? IngestTook { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClearScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClearScrollResponse.g.cs index 121e9946eb2..f2b8b4d4ac3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClearScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClearScrollResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ClearScrollResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNumFreed = System.Text.Json.JsonEncodedText.Encode("num_freed"); + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClearScrollResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propNumFreed = default; + LocalJsonProperty propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryRead(ref reader, options, PropNumFreed)) + { + continue; + } + + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearScrollResponse + { + NumFreed = propNumFreed.Value +, + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearScrollResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNumFreed, value.NumFreed); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearScrollResponseConverter))] public sealed partial class ClearScrollResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("num_freed")] public int NumFreed { get; init; } - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClosePointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClosePointInTimeResponse.g.cs index e12e0397740..a62832bb505 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClosePointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ClosePointInTimeResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ClosePointInTimeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNumFreed = System.Text.Json.JsonEncodedText.Encode("num_freed"); + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClosePointInTimeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propNumFreed = default; + LocalJsonProperty propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryRead(ref reader, options, PropNumFreed)) + { + continue; + } + + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClosePointInTimeResponse + { + NumFreed = propNumFreed.Value +, + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClosePointInTimeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNumFreed, value.NumFreed); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClosePointInTimeResponseConverter))] public sealed partial class ClosePointInTimeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("num_freed")] public int NumFreed { get; init; } - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/AllocationExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/AllocationExplainResponse.g.cs index ce1cf06e5b0..bc58e78369b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/AllocationExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/AllocationExplainResponse.g.cs @@ -18,64 +18,316 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class AllocationExplainResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllocateExplanation = System.Text.Json.JsonEncodedText.Encode("allocate_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationDelay = System.Text.Json.JsonEncodedText.Encode("allocation_delay"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationDelayInMillis = System.Text.Json.JsonEncodedText.Encode("allocation_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropCanAllocate = System.Text.Json.JsonEncodedText.Encode("can_allocate"); + private static readonly System.Text.Json.JsonEncodedText PropCanMoveToOtherNode = System.Text.Json.JsonEncodedText.Encode("can_move_to_other_node"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceCluster = System.Text.Json.JsonEncodedText.Encode("can_rebalance_cluster"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceClusterDecisions = System.Text.Json.JsonEncodedText.Encode("can_rebalance_cluster_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceToOtherNode = System.Text.Json.JsonEncodedText.Encode("can_rebalance_to_other_node"); + private static readonly System.Text.Json.JsonEncodedText PropCanRemainDecisions = System.Text.Json.JsonEncodedText.Encode("can_remain_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropCanRemainOnCurrentNode = System.Text.Json.JsonEncodedText.Encode("can_remain_on_current_node"); + private static readonly System.Text.Json.JsonEncodedText PropClusterInfo = System.Text.Json.JsonEncodedText.Encode("cluster_info"); + private static readonly System.Text.Json.JsonEncodedText PropConfiguredDelay = System.Text.Json.JsonEncodedText.Encode("configured_delay"); + private static readonly System.Text.Json.JsonEncodedText PropConfiguredDelayInMillis = System.Text.Json.JsonEncodedText.Encode("configured_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropCurrentNode = System.Text.Json.JsonEncodedText.Encode("current_node"); + private static readonly System.Text.Json.JsonEncodedText PropCurrentState = System.Text.Json.JsonEncodedText.Encode("current_state"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMoveExplanation = System.Text.Json.JsonEncodedText.Encode("move_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropNodeAllocationDecisions = System.Text.Json.JsonEncodedText.Encode("node_allocation_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropNote = System.Text.Json.JsonEncodedText.Encode("note"); + private static readonly System.Text.Json.JsonEncodedText PropPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + private static readonly System.Text.Json.JsonEncodedText PropRebalanceExplanation = System.Text.Json.JsonEncodedText.Encode("rebalance_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropRemainingDelay = System.Text.Json.JsonEncodedText.Encode("remaining_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRemainingDelayInMillis = System.Text.Json.JsonEncodedText.Encode("remaining_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropShard = System.Text.Json.JsonEncodedText.Encode("shard"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedInfo = System.Text.Json.JsonEncodedText.Encode("unassigned_info"); + + public override AllocationExplainResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllocateExplanation = default; + LocalJsonProperty propAllocationDelay = default; + LocalJsonProperty propAllocationDelayInMillis = default; + LocalJsonProperty propCanAllocate = default; + LocalJsonProperty propCanMoveToOtherNode = default; + LocalJsonProperty propCanRebalanceCluster = default; + LocalJsonProperty?> propCanRebalanceClusterDecisions = default; + LocalJsonProperty propCanRebalanceToOtherNode = default; + LocalJsonProperty?> propCanRemainDecisions = default; + LocalJsonProperty propCanRemainOnCurrentNode = default; + LocalJsonProperty propClusterInfo = default; + LocalJsonProperty propConfiguredDelay = default; + LocalJsonProperty propConfiguredDelayInMillis = default; + LocalJsonProperty propCurrentNode = default; + LocalJsonProperty propCurrentState = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propMoveExplanation = default; + LocalJsonProperty?> propNodeAllocationDecisions = default; + LocalJsonProperty propNote = default; + LocalJsonProperty propPrimary = default; + LocalJsonProperty propRebalanceExplanation = default; + LocalJsonProperty propRemainingDelay = default; + LocalJsonProperty propRemainingDelayInMillis = default; + LocalJsonProperty propShard = default; + LocalJsonProperty propUnassignedInfo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllocateExplanation.TryRead(ref reader, options, PropAllocateExplanation)) + { + continue; + } + + if (propAllocationDelay.TryRead(ref reader, options, PropAllocationDelay)) + { + continue; + } + + if (propAllocationDelayInMillis.TryRead(ref reader, options, PropAllocationDelayInMillis)) + { + continue; + } + + if (propCanAllocate.TryRead(ref reader, options, PropCanAllocate)) + { + continue; + } + + if (propCanMoveToOtherNode.TryRead(ref reader, options, PropCanMoveToOtherNode)) + { + continue; + } + + if (propCanRebalanceCluster.TryRead(ref reader, options, PropCanRebalanceCluster)) + { + continue; + } + + if (propCanRebalanceClusterDecisions.TryRead(ref reader, options, PropCanRebalanceClusterDecisions)) + { + continue; + } + + if (propCanRebalanceToOtherNode.TryRead(ref reader, options, PropCanRebalanceToOtherNode)) + { + continue; + } + + if (propCanRemainDecisions.TryRead(ref reader, options, PropCanRemainDecisions)) + { + continue; + } + + if (propCanRemainOnCurrentNode.TryRead(ref reader, options, PropCanRemainOnCurrentNode)) + { + continue; + } + + if (propClusterInfo.TryRead(ref reader, options, PropClusterInfo)) + { + continue; + } + + if (propConfiguredDelay.TryRead(ref reader, options, PropConfiguredDelay)) + { + continue; + } + + if (propConfiguredDelayInMillis.TryRead(ref reader, options, PropConfiguredDelayInMillis)) + { + continue; + } + + if (propCurrentNode.TryRead(ref reader, options, PropCurrentNode)) + { + continue; + } + + if (propCurrentState.TryRead(ref reader, options, PropCurrentState)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMoveExplanation.TryRead(ref reader, options, PropMoveExplanation)) + { + continue; + } + + if (propNodeAllocationDecisions.TryRead(ref reader, options, PropNodeAllocationDecisions)) + { + continue; + } + + if (propNote.TryRead(ref reader, options, PropNote)) + { + continue; + } + + if (propPrimary.TryRead(ref reader, options, PropPrimary)) + { + continue; + } + + if (propRebalanceExplanation.TryRead(ref reader, options, PropRebalanceExplanation)) + { + continue; + } + + if (propRemainingDelay.TryRead(ref reader, options, PropRemainingDelay)) + { + continue; + } + + if (propRemainingDelayInMillis.TryRead(ref reader, options, PropRemainingDelayInMillis)) + { + continue; + } + + if (propShard.TryRead(ref reader, options, PropShard)) + { + continue; + } + + if (propUnassignedInfo.TryRead(ref reader, options, PropUnassignedInfo)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AllocationExplainResponse + { + AllocateExplanation = propAllocateExplanation.Value +, + AllocationDelay = propAllocationDelay.Value +, + AllocationDelayInMillis = propAllocationDelayInMillis.Value +, + CanAllocate = propCanAllocate.Value +, + CanMoveToOtherNode = propCanMoveToOtherNode.Value +, + CanRebalanceCluster = propCanRebalanceCluster.Value +, + CanRebalanceClusterDecisions = propCanRebalanceClusterDecisions.Value +, + CanRebalanceToOtherNode = propCanRebalanceToOtherNode.Value +, + CanRemainDecisions = propCanRemainDecisions.Value +, + CanRemainOnCurrentNode = propCanRemainOnCurrentNode.Value +, + ClusterInfo = propClusterInfo.Value +, + ConfiguredDelay = propConfiguredDelay.Value +, + ConfiguredDelayInMillis = propConfiguredDelayInMillis.Value +, + CurrentNode = propCurrentNode.Value +, + CurrentState = propCurrentState.Value +, + Index = propIndex.Value +, + MoveExplanation = propMoveExplanation.Value +, + NodeAllocationDecisions = propNodeAllocationDecisions.Value +, + Note = propNote.Value +, + Primary = propPrimary.Value +, + RebalanceExplanation = propRebalanceExplanation.Value +, + RemainingDelay = propRemainingDelay.Value +, + RemainingDelayInMillis = propRemainingDelayInMillis.Value +, + Shard = propShard.Value +, + UnassignedInfo = propUnassignedInfo.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AllocationExplainResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllocateExplanation, value.AllocateExplanation); + writer.WriteProperty(options, PropAllocationDelay, value.AllocationDelay); + writer.WriteProperty(options, PropAllocationDelayInMillis, value.AllocationDelayInMillis); + writer.WriteProperty(options, PropCanAllocate, value.CanAllocate); + writer.WriteProperty(options, PropCanMoveToOtherNode, value.CanMoveToOtherNode); + writer.WriteProperty(options, PropCanRebalanceCluster, value.CanRebalanceCluster); + writer.WriteProperty(options, PropCanRebalanceClusterDecisions, value.CanRebalanceClusterDecisions); + writer.WriteProperty(options, PropCanRebalanceToOtherNode, value.CanRebalanceToOtherNode); + writer.WriteProperty(options, PropCanRemainDecisions, value.CanRemainDecisions); + writer.WriteProperty(options, PropCanRemainOnCurrentNode, value.CanRemainOnCurrentNode); + writer.WriteProperty(options, PropClusterInfo, value.ClusterInfo); + writer.WriteProperty(options, PropConfiguredDelay, value.ConfiguredDelay); + writer.WriteProperty(options, PropConfiguredDelayInMillis, value.ConfiguredDelayInMillis); + writer.WriteProperty(options, PropCurrentNode, value.CurrentNode); + writer.WriteProperty(options, PropCurrentState, value.CurrentState); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMoveExplanation, value.MoveExplanation); + writer.WriteProperty(options, PropNodeAllocationDecisions, value.NodeAllocationDecisions); + writer.WriteProperty(options, PropNote, value.Note); + writer.WriteProperty(options, PropPrimary, value.Primary); + writer.WriteProperty(options, PropRebalanceExplanation, value.RebalanceExplanation); + writer.WriteProperty(options, PropRemainingDelay, value.RemainingDelay); + writer.WriteProperty(options, PropRemainingDelayInMillis, value.RemainingDelayInMillis); + writer.WriteProperty(options, PropShard, value.Shard); + writer.WriteProperty(options, PropUnassignedInfo, value.UnassignedInfo); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AllocationExplainResponseConverter))] public sealed partial class AllocationExplainResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allocate_explanation")] public string? AllocateExplanation { get; init; } - [JsonInclude, JsonPropertyName("allocation_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration? AllocationDelay { get; init; } - [JsonInclude, JsonPropertyName("allocation_delay_in_millis")] public long? AllocationDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("can_allocate")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.Decision? CanAllocate { get; init; } - [JsonInclude, JsonPropertyName("can_move_to_other_node")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.Decision? CanMoveToOtherNode { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_cluster")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.Decision? CanRebalanceCluster { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_cluster_decisions")] public IReadOnlyCollection? CanRebalanceClusterDecisions { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_to_other_node")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.Decision? CanRebalanceToOtherNode { get; init; } - [JsonInclude, JsonPropertyName("can_remain_decisions")] public IReadOnlyCollection? CanRemainDecisions { get; init; } - [JsonInclude, JsonPropertyName("can_remain_on_current_node")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.Decision? CanRemainOnCurrentNode { get; init; } - [JsonInclude, JsonPropertyName("cluster_info")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.ClusterInfo? ClusterInfo { get; init; } - [JsonInclude, JsonPropertyName("configured_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration? ConfiguredDelay { get; init; } - [JsonInclude, JsonPropertyName("configured_delay_in_millis")] public long? ConfiguredDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("current_node")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.CurrentNode? CurrentNode { get; init; } - [JsonInclude, JsonPropertyName("current_state")] public string CurrentState { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("move_explanation")] public string? MoveExplanation { get; init; } - [JsonInclude, JsonPropertyName("node_allocation_decisions")] public IReadOnlyCollection? NodeAllocationDecisions { get; init; } - [JsonInclude, JsonPropertyName("note")] public string? Note { get; init; } - [JsonInclude, JsonPropertyName("primary")] public bool Primary { get; init; } - [JsonInclude, JsonPropertyName("rebalance_explanation")] public string? RebalanceExplanation { get; init; } - [JsonInclude, JsonPropertyName("remaining_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration? RemainingDelay { get; init; } - [JsonInclude, JsonPropertyName("remaining_delay_in_millis")] public long? RemainingDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("shard")] public int Shard { get; init; } - [JsonInclude, JsonPropertyName("unassigned_info")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.UnassignedInformation? UnassignedInfo { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterInfoResponse.g.cs index 6c4a5a88c82..29892443165 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterInfoResponse.g.cs @@ -18,24 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class ClusterInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + + public override ClusterInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty propHttp = default; + LocalJsonProperty propIngest = default; + LocalJsonProperty propScript = default; + LocalJsonProperty?> propThreadPool = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propHttp.TryRead(ref reader, options, PropHttp)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propThreadPool.TryRead(ref reader, options, PropThreadPool)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClusterInfoResponse + { + ClusterName = propClusterName.Value +, + Http = propHttp.Value +, + Ingest = propIngest.Value +, + Script = propScript.Value +, + ThreadPool = propThreadPool.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropHttp, value.Http); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClusterInfoResponseConverter))] public sealed partial class ClusterInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("http")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Http? Http { get; init; } - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Ingest? Ingest { get; init; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Scripting? Script { get; init; } - [JsonInclude, JsonPropertyName("thread_pool")] public IReadOnlyDictionary? ThreadPool { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterStatsResponse.g.cs index 12d77b02a34..b70f1ad6d9a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/ClusterStatsResponse.g.cs @@ -18,14 +18,111 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class ClusterStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropClusterUuid = System.Text.Json.JsonEncodedText.Encode("cluster_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTimestamp = System.Text.Json.JsonEncodedText.Encode("timestamp"); + + public override ClusterStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty propClusterUuid = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propNodes = default; + LocalJsonProperty propNodeStats = default; + LocalJsonProperty propStatus = default; + LocalJsonProperty propTimestamp = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propClusterUuid.TryRead(ref reader, options, PropClusterUuid)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTimestamp.TryRead(ref reader, options, PropTimestamp)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClusterStatsResponse + { + ClusterName = propClusterName.Value +, + ClusterUuid = propClusterUuid.Value +, + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value +, + Status = propStatus.Value +, + Timestamp = propTimestamp.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTimestamp, value.Timestamp); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClusterStatsResponseConverter))] public sealed partial class ClusterStatsResponse : ElasticsearchResponse { /// @@ -33,7 +130,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Name of the cluster, based on the cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +137,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Unique identifier for the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } /// @@ -49,7 +144,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about indices with shards assigned to selected nodes. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.ClusterIndices Indices { get; init; } /// @@ -57,7 +151,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("nodes")] public Elastic.Clients.Elasticsearch.Serverless.Cluster.ClusterNodes Nodes { get; init; } /// @@ -65,7 +158,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics? NodeStats { get; init; } /// @@ -73,7 +165,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Health status of the cluster, based on the state of its primary and replica shards. /// /// - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Serverless.HealthStatus Status { get; init; } /// @@ -81,6 +172,5 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Unix timestamp, in milliseconds, for the last time the cluster statistics were refreshed. /// /// - [JsonInclude, JsonPropertyName("timestamp")] public long Timestamp { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs index e0f3c244fef..8d636827853 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class DeleteComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteComponentTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteComponentTemplateResponseConverter))] public sealed partial class DeleteComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteComponentTemplateResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs index 01f99ea2bce..02f306dd8aa 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class GetClusterSettingsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefaults = System.Text.Json.JsonEncodedText.Encode("defaults"); + private static readonly System.Text.Json.JsonEncodedText PropPersistent = System.Text.Json.JsonEncodedText.Encode("persistent"); + private static readonly System.Text.Json.JsonEncodedText PropTransient = System.Text.Json.JsonEncodedText.Encode("transient"); + + public override GetClusterSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propDefaults = default; + LocalJsonProperty> propPersistent = default; + LocalJsonProperty> propTransient = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryRead(ref reader, options, PropDefaults)) + { + continue; + } + + if (propPersistent.TryRead(ref reader, options, PropPersistent)) + { + continue; + } + + if (propTransient.TryRead(ref reader, options, PropTransient)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetClusterSettingsResponse + { + Defaults = propDefaults.Value +, + Persistent = propPersistent.Value +, + Transient = propTransient.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetClusterSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefaults, value.Defaults); + writer.WriteProperty(options, PropPersistent, value.Persistent); + writer.WriteProperty(options, PropTransient, value.Transient); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetClusterSettingsResponseConverter))] public sealed partial class GetClusterSettingsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("defaults")] public IReadOnlyDictionary? Defaults { get; init; } - [JsonInclude, JsonPropertyName("persistent")] public IReadOnlyDictionary Persistent { get; init; } - [JsonInclude, JsonPropertyName("transient")] public IReadOnlyDictionary Transient { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs index 949e435bcb1..9b3062fb043 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class GetComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropComponentTemplates = System.Text.Json.JsonEncodedText.Encode("component_templates"); + + public override GetComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propComponentTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComponentTemplates.TryRead(ref reader, options, PropComponentTemplates)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetComponentTemplateResponse + { + ComponentTemplates = propComponentTemplates.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropComponentTemplates, value.ComponentTemplates); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetComponentTemplateResponseConverter))] public sealed partial class GetComponentTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("component_templates")] public IReadOnlyCollection ComponentTemplates { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/HealthResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/HealthResponse.g.cs index 609d064dd95..2ca8e700a19 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/HealthResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/HealthResponse.g.cs @@ -18,14 +18,221 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class HealthResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActivePrimaryShards = System.Text.Json.JsonEncodedText.Encode("active_primary_shards"); + private static readonly System.Text.Json.JsonEncodedText PropActiveShards = System.Text.Json.JsonEncodedText.Encode("active_shards"); + private static readonly System.Text.Json.JsonEncodedText PropActiveShardsPercentAsNumber = System.Text.Json.JsonEncodedText.Encode("active_shards_percent_as_number"); + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedUnassignedShards = System.Text.Json.JsonEncodedText.Encode("delayed_unassigned_shards"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropInitializingShards = System.Text.Json.JsonEncodedText.Encode("initializing_shards"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfDataNodes = System.Text.Json.JsonEncodedText.Encode("number_of_data_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfInFlightFetch = System.Text.Json.JsonEncodedText.Encode("number_of_in_flight_fetch"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfNodes = System.Text.Json.JsonEncodedText.Encode("number_of_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfPendingTasks = System.Text.Json.JsonEncodedText.Encode("number_of_pending_tasks"); + private static readonly System.Text.Json.JsonEncodedText PropRelocatingShards = System.Text.Json.JsonEncodedText.Encode("relocating_shards"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTaskMaxWaitingInQueue = System.Text.Json.JsonEncodedText.Encode("task_max_waiting_in_queue"); + private static readonly System.Text.Json.JsonEncodedText PropTaskMaxWaitingInQueueMillis = System.Text.Json.JsonEncodedText.Encode("task_max_waiting_in_queue_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedPrimaryShards = System.Text.Json.JsonEncodedText.Encode("unassigned_primary_shards"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedShards = System.Text.Json.JsonEncodedText.Encode("unassigned_shards"); + + public override HealthResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propActivePrimaryShards = default; + LocalJsonProperty propActiveShards = default; + LocalJsonProperty propActiveShardsPercentAsNumber = default; + LocalJsonProperty propClusterName = default; + LocalJsonProperty propDelayedUnassignedShards = default; + LocalJsonProperty?> propIndices = default; + LocalJsonProperty propInitializingShards = default; + LocalJsonProperty propNumberOfDataNodes = default; + LocalJsonProperty propNumberOfInFlightFetch = default; + LocalJsonProperty propNumberOfNodes = default; + LocalJsonProperty propNumberOfPendingTasks = default; + LocalJsonProperty propRelocatingShards = default; + LocalJsonProperty propStatus = default; + LocalJsonProperty propTaskMaxWaitingInQueue = default; + LocalJsonProperty propTaskMaxWaitingInQueueMillis = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propUnassignedPrimaryShards = default; + LocalJsonProperty propUnassignedShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActivePrimaryShards.TryRead(ref reader, options, PropActivePrimaryShards)) + { + continue; + } + + if (propActiveShards.TryRead(ref reader, options, PropActiveShards)) + { + continue; + } + + if (propActiveShardsPercentAsNumber.TryRead(ref reader, options, PropActiveShardsPercentAsNumber)) + { + continue; + } + + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propDelayedUnassignedShards.TryRead(ref reader, options, PropDelayedUnassignedShards)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propInitializingShards.TryRead(ref reader, options, PropInitializingShards)) + { + continue; + } + + if (propNumberOfDataNodes.TryRead(ref reader, options, PropNumberOfDataNodes)) + { + continue; + } + + if (propNumberOfInFlightFetch.TryRead(ref reader, options, PropNumberOfInFlightFetch)) + { + continue; + } + + if (propNumberOfNodes.TryRead(ref reader, options, PropNumberOfNodes)) + { + continue; + } + + if (propNumberOfPendingTasks.TryRead(ref reader, options, PropNumberOfPendingTasks)) + { + continue; + } + + if (propRelocatingShards.TryRead(ref reader, options, PropRelocatingShards)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTaskMaxWaitingInQueue.TryRead(ref reader, options, PropTaskMaxWaitingInQueue)) + { + continue; + } + + if (propTaskMaxWaitingInQueueMillis.TryRead(ref reader, options, PropTaskMaxWaitingInQueueMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propUnassignedPrimaryShards.TryRead(ref reader, options, PropUnassignedPrimaryShards)) + { + continue; + } + + if (propUnassignedShards.TryRead(ref reader, options, PropUnassignedShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HealthResponse + { + ActivePrimaryShards = propActivePrimaryShards.Value +, + ActiveShards = propActiveShards.Value +, + ActiveShardsPercentAsNumber = propActiveShardsPercentAsNumber.Value +, + ClusterName = propClusterName.Value +, + DelayedUnassignedShards = propDelayedUnassignedShards.Value +, + Indices = propIndices.Value +, + InitializingShards = propInitializingShards.Value +, + NumberOfDataNodes = propNumberOfDataNodes.Value +, + NumberOfInFlightFetch = propNumberOfInFlightFetch.Value +, + NumberOfNodes = propNumberOfNodes.Value +, + NumberOfPendingTasks = propNumberOfPendingTasks.Value +, + RelocatingShards = propRelocatingShards.Value +, + Status = propStatus.Value +, + TaskMaxWaitingInQueue = propTaskMaxWaitingInQueue.Value +, + TaskMaxWaitingInQueueMillis = propTaskMaxWaitingInQueueMillis.Value +, + TimedOut = propTimedOut.Value +, + UnassignedPrimaryShards = propUnassignedPrimaryShards.Value +, + UnassignedShards = propUnassignedShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActivePrimaryShards, value.ActivePrimaryShards); + writer.WriteProperty(options, PropActiveShards, value.ActiveShards); + writer.WriteProperty(options, PropActiveShardsPercentAsNumber, value.ActiveShardsPercentAsNumber); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropDelayedUnassignedShards, value.DelayedUnassignedShards); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropInitializingShards, value.InitializingShards); + writer.WriteProperty(options, PropNumberOfDataNodes, value.NumberOfDataNodes); + writer.WriteProperty(options, PropNumberOfInFlightFetch, value.NumberOfInFlightFetch); + writer.WriteProperty(options, PropNumberOfNodes, value.NumberOfNodes); + writer.WriteProperty(options, PropNumberOfPendingTasks, value.NumberOfPendingTasks); + writer.WriteProperty(options, PropRelocatingShards, value.RelocatingShards); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTaskMaxWaitingInQueue, value.TaskMaxWaitingInQueue); + writer.WriteProperty(options, PropTaskMaxWaitingInQueueMillis, value.TaskMaxWaitingInQueueMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropUnassignedPrimaryShards, value.UnassignedPrimaryShards); + writer.WriteProperty(options, PropUnassignedShards, value.UnassignedShards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HealthResponseConverter))] public sealed partial class HealthResponse : ElasticsearchResponse { /// @@ -33,7 +240,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of active primary shards. /// /// - [JsonInclude, JsonPropertyName("active_primary_shards")] public int ActivePrimaryShards { get; init; } /// @@ -41,7 +247,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The total number of active primary and replica shards. /// /// - [JsonInclude, JsonPropertyName("active_shards")] public int ActiveShards { get; init; } /// @@ -49,7 +254,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The ratio of active shards in the cluster expressed as a percentage. /// /// - [JsonInclude, JsonPropertyName("active_shards_percent_as_number")] public double ActiveShardsPercentAsNumber { get; init; } /// @@ -57,7 +261,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The name of the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -65,10 +268,7 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards whose allocation has been delayed by the timeout settings. /// /// - [JsonInclude, JsonPropertyName("delayed_unassigned_shards")] public int DelayedUnassignedShards { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Cluster.IndexHealthStats))] public IReadOnlyDictionary? Indices { get; init; } /// @@ -76,7 +276,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are under initialization. /// /// - [JsonInclude, JsonPropertyName("initializing_shards")] public int InitializingShards { get; init; } /// @@ -84,7 +283,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of nodes that are dedicated data nodes. /// /// - [JsonInclude, JsonPropertyName("number_of_data_nodes")] public int NumberOfDataNodes { get; init; } /// @@ -92,7 +290,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of unfinished fetches. /// /// - [JsonInclude, JsonPropertyName("number_of_in_flight_fetch")] public int NumberOfInFlightFetch { get; init; } /// @@ -100,7 +297,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of nodes within the cluster. /// /// - [JsonInclude, JsonPropertyName("number_of_nodes")] public int NumberOfNodes { get; init; } /// @@ -108,7 +304,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of cluster-level changes that have not yet been executed. /// /// - [JsonInclude, JsonPropertyName("number_of_pending_tasks")] public int NumberOfPendingTasks { get; init; } /// @@ -116,9 +311,7 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are under relocation. /// /// - [JsonInclude, JsonPropertyName("relocating_shards")] public int RelocatingShards { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Serverless.HealthStatus Status { get; init; } /// @@ -126,7 +319,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The time since the earliest initiated task is waiting for being performed. /// /// - [JsonInclude, JsonPropertyName("task_max_waiting_in_queue")] public Elastic.Clients.Elasticsearch.Serverless.Duration? TaskMaxWaitingInQueue { get; init; } /// @@ -134,7 +326,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The time expressed in milliseconds since the earliest initiated task is waiting for being performed. /// /// - [JsonInclude, JsonPropertyName("task_max_waiting_in_queue_millis")] public long TaskMaxWaitingInQueueMillis { get; init; } /// @@ -142,7 +333,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// If false the response returned within the period of time that is specified by the timeout parameter (30s by default) /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } /// @@ -150,7 +340,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of primary shards that are not allocated. /// /// - [JsonInclude, JsonPropertyName("unassigned_primary_shards")] public int UnassignedPrimaryShards { get; init; } /// @@ -158,6 +347,5 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are not allocated. /// /// - [JsonInclude, JsonPropertyName("unassigned_shards")] public int UnassignedShards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PendingTasksResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PendingTasksResponse.g.cs index d4cd024db8e..dbad8cde7cf 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PendingTasksResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PendingTasksResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class PendingTasksResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override PendingTasksResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PendingTasksResponse + { + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PendingTasksResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PendingTasksResponseConverter))] public sealed partial class PendingTasksResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("tasks")] public IReadOnlyCollection Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs index 6b23a00a031..3a6fc13e92d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Cluster; +internal sealed partial class PutComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutComponentTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutComponentTemplateResponseConverter))] public sealed partial class PutComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutComponentTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CountResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CountResponse.g.cs index f5f128d25bc..938a4706c0a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CountResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CountResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class CountResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override CountResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CountResponse + { + Count = propCount.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CountResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CountResponseConverter))] public sealed partial class CountResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } } \ No newline at end of file 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 effdf74767f..51590692fad 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateRequest.g.cs @@ -94,7 +94,7 @@ public sealed partial class CreateRequestParameters : RequestParameters /// 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, ISelfSerializable +public sealed partial class CreateRequest : PlainRequest, ISelfTwoWaySerializable { public CreateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id id) : base(r => r.Required("index", index).Required("id", id)) { @@ -168,13 +168,17 @@ public CreateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// [JsonIgnore] 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) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { settings.SourceSerializer.Serialize(Document, writer); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Document = settings.SourceSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateResponse.g.cs index 17ad3a8848c..c1ae9fcab9f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/CreateResponse.g.cs @@ -18,30 +18,129 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class CreateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override CreateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propForcedRefresh = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propResult = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateResponseConverter))] public sealed partial class CreateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryResponse.g.cs index a8cb2a4cddf..df09c6659c7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryResponse.g.cs @@ -18,46 +18,217 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class DeleteByQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropSliceId = System.Text.Json.JsonEncodedText.Encode("slice_id"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntil = System.Text.Json.JsonEncodedText.Encode("throttled_until"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override DeleteByQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBatches = default; + LocalJsonProperty propDeleted = default; + LocalJsonProperty?> propFailures = default; + LocalJsonProperty propNoops = default; + LocalJsonProperty propRequestsPerSecond = default; + LocalJsonProperty propRetries = default; + LocalJsonProperty propSliceId = default; + LocalJsonProperty propTask = default; + LocalJsonProperty propThrottled = default; + LocalJsonProperty propThrottledMillis = default; + LocalJsonProperty propThrottledUntil = default; + LocalJsonProperty propThrottledUntilMillis = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + LocalJsonProperty propTotal = default; + LocalJsonProperty propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propSliceId.TryRead(ref reader, options, PropSliceId)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottled.TryRead(ref reader, options, PropThrottled)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntil.TryRead(ref reader, options, PropThrottledUntil)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteByQueryResponse + { + Batches = propBatches.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + SliceId = propSliceId.Value +, + Task = propTask.Value +, + Throttled = propThrottled.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntil = propThrottledUntil.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteByQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropSliceId, value.SliceId); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottled, value.Throttled); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteByQueryResponseConverter))] public sealed partial class DeleteByQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Serverless.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.Serverless.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.Serverless.Duration? ThrottledUntil { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs index 8873be7f541..727347c4446 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs @@ -18,17 +18,83 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class DeleteByQueryRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodeFailures = System.Text.Json.JsonEncodedText.Encode("node_failures"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override DeleteByQueryRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propNodeFailures = default; + LocalJsonProperty?> propNodes = default; + LocalJsonProperty?> propTaskFailures = default; + LocalJsonProperty propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryRead(ref reader, options, PropNodeFailures)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propTaskFailures.TryRead(ref reader, options, PropTaskFailures)) + { + continue; + } + + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteByQueryRethrottleResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteByQueryRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteByQueryRethrottleResponseConverter))] public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +102,7 @@ public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchRespo /// Task information grouped by node, if group_by was set to node (the default). /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary? Nodes { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } /// @@ -47,6 +111,5 @@ public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchRespo /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Serverless.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteResponse.g.cs index 14f7602e577..117dfbe12e2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteResponse.g.cs @@ -18,30 +18,129 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class DeleteResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override DeleteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propForcedRefresh = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propResult = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteResponseConverter))] public sealed partial class DeleteResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteScriptResponse.g.cs index a12cef4ef93..15174dbe7d5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/DeleteScriptResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class DeleteScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteScriptResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteScriptResponseConverter))] public sealed partial class DeleteScriptResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteScriptResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/DeletePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/DeletePolicyResponse.g.cs index ddcc0a34a0c..08aad0f3c00 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/DeletePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/DeletePolicyResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class DeletePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeletePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeletePolicyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeletePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePolicyResponseConverter))] public sealed partial class DeletePolicyResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeletePolicyResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/EnrichStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/EnrichStatsResponse.g.cs index 8bfd8cf71e0..318c579ca31 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/EnrichStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/EnrichStatsResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class EnrichStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCacheStats = System.Text.Json.JsonEncodedText.Encode("cache_stats"); + private static readonly System.Text.Json.JsonEncodedText PropCoordinatorStats = System.Text.Json.JsonEncodedText.Encode("coordinator_stats"); + private static readonly System.Text.Json.JsonEncodedText PropExecutingPolicies = System.Text.Json.JsonEncodedText.Encode("executing_policies"); + + public override EnrichStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propCacheStats = default; + LocalJsonProperty> propCoordinatorStats = default; + LocalJsonProperty> propExecutingPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCacheStats.TryRead(ref reader, options, PropCacheStats)) + { + continue; + } + + if (propCoordinatorStats.TryRead(ref reader, options, PropCoordinatorStats)) + { + continue; + } + + if (propExecutingPolicies.TryRead(ref reader, options, PropExecutingPolicies)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrichStatsResponse + { + CacheStats = propCacheStats.Value +, + CoordinatorStats = propCoordinatorStats.Value +, + ExecutingPolicies = propExecutingPolicies.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCacheStats, value.CacheStats); + writer.WriteProperty(options, PropCoordinatorStats, value.CoordinatorStats); + writer.WriteProperty(options, PropExecutingPolicies, value.ExecutingPolicies); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrichStatsResponseConverter))] public sealed partial class EnrichStatsResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about the enrich cache stats on each ingest node. /// /// - [JsonInclude, JsonPropertyName("cache_stats")] public IReadOnlyCollection? CacheStats { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about each coordinating ingest node for configured enrich processors. /// /// - [JsonInclude, JsonPropertyName("coordinator_stats")] public IReadOnlyCollection CoordinatorStats { get; init; } /// @@ -49,6 +104,5 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about each enrich policy that is currently executing. /// /// - [JsonInclude, JsonPropertyName("executing_policies")] public IReadOnlyCollection ExecutingPolicies { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs index 456ddb5ba4f..0f6451c4bef 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class ExecutePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTaskId = System.Text.Json.JsonEncodedText.Encode("task_id"); + + public override ExecutePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propStatus = default; + LocalJsonProperty propTaskId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTaskId.TryRead(ref reader, options, PropTaskId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecutePolicyResponse + { + Status = propStatus.Value +, + TaskId = propTaskId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecutePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTaskId, value.TaskId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecutePolicyResponseConverter))] public sealed partial class ExecutePolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Serverless.Enrich.ExecuteEnrichPolicyStatus? Status { get; init; } - [JsonInclude, JsonPropertyName("task_id")] public Elastic.Clients.Elasticsearch.Serverless.TaskId? TaskId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/GetPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/GetPolicyResponse.g.cs index a6859836745..7e10f4bc7b4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/GetPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/GetPolicyResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class GetPolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPolicies = System.Text.Json.JsonEncodedText.Encode("policies"); + + public override GetPolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicies.TryRead(ref reader, options, PropPolicies)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetPolicyResponse + { + Policies = propPolicies.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetPolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPolicies, value.Policies); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetPolicyResponseConverter))] public sealed partial class GetPolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("policies")] public IReadOnlyCollection Policies { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/PutPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/PutPolicyResponse.g.cs index b139f4781c1..d70e1531faa 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/PutPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Enrich/PutPolicyResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class PutPolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutPolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutPolicyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutPolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPolicyResponseConverter))] public sealed partial class PutPolicyResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutPolicyResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlDeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlDeleteResponse.g.cs index 38f55f2b5cc..989e15608a7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlDeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlDeleteResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Eql; +internal sealed partial class EqlDeleteResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override EqlDeleteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlDeleteResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlDeleteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EqlDeleteResponseConverter))] public sealed partial class EqlDeleteResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class EqlDeleteResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlGetResponse.g.cs index 19dc034e90b..d7caec39f45 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlGetResponse.g.cs @@ -18,14 +18,128 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Eql; +internal sealed partial class EqlGetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShardFailures = System.Text.Json.JsonEncodedText.Encode("shard_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override EqlGetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propHits = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty?> propShardFailures = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShardFailures.TryRead(ref reader, options, PropShardFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlGetResponse + { + Hits = propHits.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + ShardFailures = propShardFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlGetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlGetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlGetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(EqlGetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(EqlGetResponseConverterFactory))] public sealed partial class EqlGetResponse : ElasticsearchResponse { /// @@ -33,7 +147,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Serverless.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +154,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +161,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -57,7 +168,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the search request is still executing. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } /// @@ -65,7 +175,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Contains information about shard failures (if any), in case allow_partial_search_results=true /// /// - [JsonInclude, JsonPropertyName("shard_failures")] public IReadOnlyCollection? ShardFailures { get; init; } /// @@ -73,7 +182,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the request timed out before completion. /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } /// @@ -81,6 +189,5 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Milliseconds it took Elasticsearch to execute the request. /// /// - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchRequest.g.cs index 41ebfb7e630..0b09a1dd39b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -43,6 +44,199 @@ public sealed partial class EqlSearchRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } +internal sealed partial class EqlSearchRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSearchResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_search_results"); + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSequenceResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_sequence_results"); + private static readonly System.Text.Json.JsonEncodedText PropCaseSensitive = System.Text.Json.JsonEncodedText.Encode("case_sensitive"); + private static readonly System.Text.Json.JsonEncodedText PropEventCategoryField = System.Text.Json.JsonEncodedText.Encode("event_category_field"); + private static readonly System.Text.Json.JsonEncodedText PropFetchSize = System.Text.Json.JsonEncodedText.Encode("fetch_size"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropKeepAlive = System.Text.Json.JsonEncodedText.Encode("keep_alive"); + private static readonly System.Text.Json.JsonEncodedText PropKeepOnCompletion = System.Text.Json.JsonEncodedText.Encode("keep_on_completion"); + private static readonly System.Text.Json.JsonEncodedText PropMaxSamplesPerKey = System.Text.Json.JsonEncodedText.Encode("max_samples_per_key"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropResultPosition = System.Text.Json.JsonEncodedText.Encode("result_position"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropTiebreakerField = System.Text.Json.JsonEncodedText.Encode("tiebreaker_field"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + private static readonly System.Text.Json.JsonEncodedText PropWaitForCompletionTimeout = System.Text.Json.JsonEncodedText.Encode("wait_for_completion_timeout"); + + public override EqlSearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowPartialSearchResults = default; + LocalJsonProperty propAllowPartialSequenceResults = default; + LocalJsonProperty propCaseSensitive = default; + LocalJsonProperty propEventCategoryField = default; + LocalJsonProperty propFetchSize = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propKeepAlive = default; + LocalJsonProperty propKeepOnCompletion = default; + LocalJsonProperty propMaxSamplesPerKey = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propResultPosition = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propTiebreakerField = default; + LocalJsonProperty propTimestampField = default; + LocalJsonProperty propWaitForCompletionTimeout = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowPartialSearchResults.TryRead(ref reader, options, PropAllowPartialSearchResults)) + { + continue; + } + + if (propAllowPartialSequenceResults.TryRead(ref reader, options, PropAllowPartialSequenceResults)) + { + continue; + } + + if (propCaseSensitive.TryRead(ref reader, options, PropCaseSensitive)) + { + continue; + } + + if (propEventCategoryField.TryRead(ref reader, options, PropEventCategoryField)) + { + continue; + } + + if (propFetchSize.TryRead(ref reader, options, PropFetchSize)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormat>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propKeepAlive.TryRead(ref reader, options, PropKeepAlive)) + { + continue; + } + + if (propKeepOnCompletion.TryRead(ref reader, options, PropKeepOnCompletion)) + { + continue; + } + + if (propMaxSamplesPerKey.TryRead(ref reader, options, PropMaxSamplesPerKey)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propResultPosition.TryRead(ref reader, options, PropResultPosition)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propTiebreakerField.TryRead(ref reader, options, PropTiebreakerField)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + if (propWaitForCompletionTimeout.TryRead(ref reader, options, PropWaitForCompletionTimeout)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlSearchRequest + { + AllowPartialSearchResults = propAllowPartialSearchResults.Value + , + AllowPartialSequenceResults = propAllowPartialSequenceResults.Value + , + CaseSensitive = propCaseSensitive.Value + , + EventCategoryField = propEventCategoryField.Value + , + FetchSize = propFetchSize.Value + , + Fields = propFields.Value + , + Filter = propFilter.Value + , + KeepAlive = propKeepAlive.Value + , + KeepOnCompletion = propKeepOnCompletion.Value + , + MaxSamplesPerKey = propMaxSamplesPerKey.Value + , + Query = propQuery.Value + , + ResultPosition = propResultPosition.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + Size = propSize.Value + , + TiebreakerField = propTiebreakerField.Value + , + TimestampField = propTimestampField.Value + , + WaitForCompletionTimeout = propWaitForCompletionTimeout.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowPartialSearchResults, value.AllowPartialSearchResults); + writer.WriteProperty(options, PropAllowPartialSequenceResults, value.AllowPartialSequenceResults); + writer.WriteProperty(options, PropCaseSensitive, value.CaseSensitive); + writer.WriteProperty(options, PropEventCategoryField, value.EventCategoryField); + writer.WriteProperty(options, PropFetchSize, value.FetchSize); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormat>)); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropKeepAlive, value.KeepAlive); + writer.WriteProperty(options, PropKeepOnCompletion, value.KeepOnCompletion); + writer.WriteProperty(options, PropMaxSamplesPerKey, value.MaxSamplesPerKey); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropResultPosition, value.ResultPosition); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropTiebreakerField, value.TiebreakerField); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteProperty(options, PropWaitForCompletionTimeout, value.WaitForCompletionTimeout); + writer.WriteEndObject(); + } +} + /// /// /// Get EQL search results. @@ -50,6 +244,7 @@ public sealed partial class EqlSearchRequestParameters : RequestParameters /// EQL assumes each document in a data stream or index corresponds to an event. /// /// +[JsonConverter(typeof(EqlSearchRequestConverter))] public sealed partial class EqlSearchRequest : PlainRequest { public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices) : base(r => r.Required("index", indices)) @@ -64,9 +259,7 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices internal override string OperationName => "eql.search"; - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -74,13 +267,9 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// If true, missing or closed indices are not included in the response. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } - [JsonInclude, JsonPropertyName("allow_partial_search_results")] public bool? AllowPartialSearchResults { get; set; } - [JsonInclude, JsonPropertyName("allow_partial_sequence_results")] public bool? AllowPartialSequenceResults { get; set; } - [JsonInclude, JsonPropertyName("case_sensitive")] public bool? CaseSensitive { get; set; } /// @@ -88,7 +277,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Field containing the event classification, such as process, file, or network. /// /// - [JsonInclude, JsonPropertyName("event_category_field")] public Elastic.Clients.Elasticsearch.Serverless.Field? EventCategoryField { get; set; } /// @@ -96,7 +284,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Maximum number of events to search at a time for sequence queries. /// /// - [JsonInclude, JsonPropertyName("fetch_size")] public int? FetchSize { get; set; } /// @@ -104,8 +291,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Array of wildcard (*) patterns. The response returns values for field names matching these patterns in the fields property of each hit. /// /// - [JsonInclude, JsonPropertyName("fields")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldAndFormat))] public ICollection? Fields { get; set; } /// @@ -113,12 +298,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Query, written in Query DSL, used to filter the events on which the EQL query runs. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } - [JsonInclude, JsonPropertyName("keep_alive")] public Elastic.Clients.Elasticsearch.Serverless.Duration? KeepAlive { get; set; } - [JsonInclude, JsonPropertyName("keep_on_completion")] public bool? KeepOnCompletion { get; set; } /// @@ -128,7 +309,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// max_samples_per_key parameter. Pipes are not supported for sample queries. /// /// - [JsonInclude, JsonPropertyName("max_samples_per_key")] public int? MaxSamplesPerKey { get; set; } /// @@ -136,11 +316,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// EQL query you wish to run. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("result_position")] public Elastic.Clients.Elasticsearch.Serverless.Eql.ResultPosition? ResultPosition { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -148,7 +325,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// For basic queries, the maximum number of matching events to return. Defaults to 10 /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -156,7 +332,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Field used to sort hits with the same timestamp in ascending order /// /// - [JsonInclude, JsonPropertyName("tiebreaker_field")] public Elastic.Clients.Elasticsearch.Serverless.Field? TiebreakerField { get; set; } /// @@ -164,9 +339,7 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Field containing event timestamp. Default "@timestamp" /// /// - [JsonInclude, JsonPropertyName("timestamp_field")] public Elastic.Clients.Elasticsearch.Serverless.Field? TimestampField { get; set; } - [JsonInclude, JsonPropertyName("wait_for_completion_timeout")] public Elastic.Clients.Elasticsearch.Serverless.Duration? WaitForCompletionTimeout { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchResponse.g.cs index c33426f84df..a18bdebebde 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/EqlSearchResponse.g.cs @@ -18,14 +18,128 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Eql; +internal sealed partial class EqlSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShardFailures = System.Text.Json.JsonEncodedText.Encode("shard_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override EqlSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propHits = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty?> propShardFailures = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShardFailures.TryRead(ref reader, options, PropShardFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlSearchResponse + { + Hits = propHits.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + ShardFailures = propShardFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(EqlSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(EqlSearchResponseConverterFactory))] public sealed partial class EqlSearchResponse : ElasticsearchResponse { /// @@ -33,7 +147,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Serverless.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +154,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +161,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -57,7 +168,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the search request is still executing. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } /// @@ -65,7 +175,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Contains information about shard failures (if any), in case allow_partial_search_results=true /// /// - [JsonInclude, JsonPropertyName("shard_failures")] public IReadOnlyCollection? ShardFailures { get; init; } /// @@ -73,7 +182,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the request timed out before completion. /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } /// @@ -81,6 +189,5 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Milliseconds it took Elasticsearch to execute the request. /// /// - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/GetEqlStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/GetEqlStatusResponse.g.cs index 5112f40661b..562b19430a1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/GetEqlStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Eql/GetEqlStatusResponse.g.cs @@ -18,14 +18,101 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Eql; +internal sealed partial class GetEqlStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetEqlStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompletionStatus = default; + LocalJsonProperty propExpirationTimeInMillis = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetEqlStatusResponse + { + CompletionStatus = propCompletionStatus.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetEqlStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetEqlStatusResponseConverter))] public sealed partial class GetEqlStatusResponse : ElasticsearchResponse { /// @@ -33,7 +120,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// For a completed search shows the http status code of the completed search. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -41,7 +127,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// Shows a timestamp when the eql search will be expired, in milliseconds since the Unix epoch. When this time is reached, the search and its results are deleted, even if the search is still ongoing. /// /// - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long? ExpirationTimeInMillis { get; init; } /// @@ -49,7 +134,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -57,7 +141,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// If true, the search request is still executing. If false, the search is completed. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -65,7 +148,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. This could be because either the search is still running (is_running status is false), or because it is already completed (is_running status is true) and results are partial due to failures or timeouts. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -73,6 +155,5 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// For a running search shows a timestamp when the eql search started, in milliseconds since the Unix epoch. /// /// - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long? StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ExplainResponse.g.cs index 6925c56fc6f..77685838faf 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ExplainResponse.g.cs @@ -18,24 +18,113 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ExplainResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropExplanation = System.Text.Json.JsonEncodedText.Encode("explanation"); + private static readonly System.Text.Json.JsonEncodedText PropGet = System.Text.Json.JsonEncodedText.Encode("get"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropMatched = System.Text.Json.JsonEncodedText.Encode("matched"); + + public override ExplainResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propExplanation = default; + LocalJsonProperty?> propGet = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propMatched = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryRead(ref reader, options, PropExplanation)) + { + continue; + } + + if (propGet.TryRead(ref reader, options, PropGet)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMatched.TryRead(ref reader, options, PropMatched)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainResponse + { + Explanation = propExplanation.Value +, + Get = propGet.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Matched = propMatched.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExplanation, value.Explanation); + writer.WriteProperty(options, PropGet, value.Get); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMatched, value.Matched); + writer.WriteEndObject(); + } +} + +internal sealed partial class ExplainResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ExplainResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(ExplainResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(ExplainResponseConverterFactory))] public sealed partial class ExplainResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("explanation")] public Elastic.Clients.Elasticsearch.Serverless.Core.Explain.ExplanationDetail? Explanation { get; init; } - [JsonInclude, JsonPropertyName("get")] public Elastic.Clients.Elasticsearch.Serverless.InlineGet? Get { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("matched")] public bool Matched { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsRequest.g.cs index c947c938007..277c8c4b740 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -84,6 +85,59 @@ public sealed partial class FieldCapsRequestParameters : RequestParameters public ICollection? Types { get => Q?>("types"); set => Q("types", value); } } +internal sealed partial class FieldCapsRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndexFilter = System.Text.Json.JsonEncodedText.Encode("index_filter"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + + public override FieldCapsRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFields = default; + LocalJsonProperty propIndexFilter = default; + LocalJsonProperty?> propRuntimeMappings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIndexFilter.TryRead(ref reader, options, PropIndexFilter)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapsRequest + { + Fields = propFields.Value + , + IndexFilter = propIndexFilter.Value + , + RuntimeMappings = propRuntimeMappings.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapsRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIndexFilter, value.IndexFilter); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteEndObject(); + } +} + /// /// /// Get the field capabilities. @@ -97,6 +151,7 @@ public sealed partial class FieldCapsRequestParameters : RequestParameters /// For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the keyword family. /// /// +[JsonConverter(typeof(FieldCapsRequestConverter))] public sealed partial class FieldCapsRequest : PlainRequest { public FieldCapsRequest() @@ -122,7 +177,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -130,7 +184,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -138,7 +191,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent /// /// - [JsonIgnore] public string? Filters { get => Q("filters"); set => Q("filters", value); } /// @@ -146,7 +198,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// If true, missing or closed indices are not included in the response. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -154,7 +205,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// If false, empty fields are not included in the response. /// /// - [JsonIgnore] public bool? IncludeEmptyFields { get => Q("include_empty_fields"); set => Q("include_empty_fields", value); } /// @@ -162,7 +212,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// If true, unmapped fields are included in the response. /// /// - [JsonIgnore] public bool? IncludeUnmapped { get => Q("include_unmapped"); set => Q("include_unmapped", value); } /// @@ -170,7 +219,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// Only return results for fields that have one of the types in the list /// /// - [JsonIgnore] public ICollection? Types { get => Q?>("types"); set => Q("types", value); } /// @@ -178,8 +226,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// List of fields to retrieve capabilities for. Wildcard (*) expressions are supported. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -187,7 +233,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// Allows to filter indices if the provided query rewrites to match_none on every shard. /// /// - [JsonInclude, JsonPropertyName("index_filter")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? IndexFilter { get; set; } /// @@ -196,7 +241,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indice /// These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsResponse.g.cs index b812902de68..b4e3b046129 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/FieldCapsResponse.g.cs @@ -18,20 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class FieldCapsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override FieldCapsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>> propFields = default; + LocalJsonProperty> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapsResponse + { + Fields = propFields.Value +, + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIndices, value.Indices, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCapsResponseConverter))] public sealed partial class FieldCapsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyDictionary))] public IReadOnlyDictionary> Fields { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetResponse.g.cs index 6991ba6a6f9..e4fdfe776e2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetResponse.g.cs @@ -18,35 +18,168 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class GetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override GetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFields = default; + LocalJsonProperty propFound = default; + LocalJsonProperty propId = default; + LocalJsonProperty?> propIgnored = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetResponse + { + Fields = propFields.Value +, + Found = propFound.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetResponseConverterFactory))] public sealed partial class GetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.FieldValues? Fields { get; init; } - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetScriptResponse.g.cs index e283ddb5ab6..576bfb0a2e0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/GetScriptResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class GetScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override GetScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFound = default; + LocalJsonProperty propId = default; + LocalJsonProperty propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptResponse + { + Found = propFound.Value +, + Id = propId.Value +, + Script = propScript.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptResponseConverter))] public sealed partial class GetScriptResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.StoredScript? Script { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Graph/ExploreResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Graph/ExploreResponse.g.cs index b4c16e5ce14..a5412d3cb5b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Graph/ExploreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Graph/ExploreResponse.g.cs @@ -18,24 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Graph; +internal sealed partial class ExploreResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropConnections = System.Text.Json.JsonEncodedText.Encode("connections"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropVertices = System.Text.Json.JsonEncodedText.Encode("vertices"); + + public override ExploreResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propConnections = default; + LocalJsonProperty> propFailures = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + LocalJsonProperty> propVertices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propConnections.TryRead(ref reader, options, PropConnections)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propVertices.TryRead(ref reader, options, PropVertices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExploreResponse + { + Connections = propConnections.Value +, + Failures = propFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Vertices = propVertices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExploreResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropConnections, value.Connections); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropVertices, value.Vertices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExploreResponseConverter))] public sealed partial class ExploreResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("connections")] public IReadOnlyCollection Connections { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection Failures { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("vertices")] public IReadOnlyCollection Vertices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/HealthReportResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/HealthReportResponse.g.cs index dc6e11408ba..2a3b4255fbc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/HealthReportResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/HealthReportResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class HealthReportResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropIndicators = System.Text.Json.JsonEncodedText.Encode("indicators"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + + public override HealthReportResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty propIndicators = default; + LocalJsonProperty propStatus = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propIndicators.TryRead(ref reader, options, PropIndicators)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HealthReportResponse + { + ClusterName = propClusterName.Value +, + Indicators = propIndicators.Value +, + Status = propStatus.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthReportResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropIndicators, value.Indicators); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HealthReportResponseConverter))] public sealed partial class HealthReportResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("indicators")] public Elastic.Clients.Elasticsearch.Serverless.Core.HealthReport.Indicators Indicators { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Serverless.Core.HealthReport.IndicatorHealthStatus? Status { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs index c26f3bc5ee2..13b21c496c3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,119 @@ public sealed partial class AnalyzeIndexRequestParameters : RequestParameters { } +internal sealed partial class AnalyzeIndexRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropCharFilter = System.Text.Json.JsonEncodedText.Encode("char_filter"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropNormalizer = System.Text.Json.JsonEncodedText.Encode("normalizer"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText PropTokenizer = System.Text.Json.JsonEncodedText.Encode("tokenizer"); + + public override AnalyzeIndexRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty?> propAttributes = default; + LocalJsonProperty?> propCharFilter = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty propField = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propNormalizer = default; + LocalJsonProperty?> propText = default; + LocalJsonProperty propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAttributes.TryRead(ref reader, options, PropAttributes)) + { + continue; + } + + if (propCharFilter.TryRead(ref reader, options, PropCharFilter)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propNormalizer.TryRead(ref reader, options, PropNormalizer)) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propTokenizer.TryRead(ref reader, options, PropTokenizer)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalyzeIndexRequest + { + Analyzer = propAnalyzer.Value +, + Attributes = propAttributes.Value +, + CharFilter = propCharFilter.Value +, + Explain = propExplain.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + Normalizer = propNormalizer.Value +, + Text = propText.Value +, + Tokenizer = propTokenizer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalyzeIndexRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAttributes, value.Attributes); + writer.WriteProperty(options, PropCharFilter, value.CharFilter); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropNormalizer, value.Normalizer); + writer.WriteProperty(options, PropText, value.Text, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer); + writer.WriteEndObject(); + } +} + /// /// /// Get tokens from text analysis. @@ -46,6 +160,7 @@ public sealed partial class AnalyzeIndexRequestParameters : RequestParameters /// The _analyze endpoint without a specified index will always use 10000 as its limit. /// /// +[JsonConverter(typeof(AnalyzeIndexRequestConverter))] public sealed partial class AnalyzeIndexRequest : PlainRequest { public AnalyzeIndexRequest() @@ -70,7 +185,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// This could be a built-in analyzer, or an analyzer that’s been configured in the index. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -78,7 +192,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// Array of token attributes used to filter the output of the explain parameter. /// /// - [JsonInclude, JsonPropertyName("attributes")] public ICollection? Attributes { get; set; } /// @@ -86,7 +199,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// Array of character filters used to preprocess characters before the tokenizer. /// /// - [JsonInclude, JsonPropertyName("char_filter")] public ICollection? CharFilter { get; set; } /// @@ -94,7 +206,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// If true, the response includes token attributes and additional details. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -104,7 +215,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// If specified, the analyzer parameter overrides this value. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } /// @@ -112,7 +222,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// Array of token filters used to apply after the tokenizer. /// /// - [JsonInclude, JsonPropertyName("filter")] public ICollection? Filter { get; set; } /// @@ -120,7 +229,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// Normalizer to use to convert text into a single token. /// /// - [JsonInclude, JsonPropertyName("normalizer")] public string? Normalizer { get; set; } /// @@ -129,8 +237,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// If an array of strings is provided, it is analyzed as a multi-value field. /// /// - [JsonInclude, JsonPropertyName("text")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Text { get; set; } /// @@ -138,7 +244,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName? i /// Tokenizer to use to convert text into tokens. /// /// - [JsonInclude, JsonPropertyName("tokenizer")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.ITokenizer? Tokenizer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs index e2a51c4d93c..21f8c9a9047 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class AnalyzeIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDetail = System.Text.Json.JsonEncodedText.Encode("detail"); + private static readonly System.Text.Json.JsonEncodedText PropTokens = System.Text.Json.JsonEncodedText.Encode("tokens"); + + public override AnalyzeIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDetail = default; + LocalJsonProperty?> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetail.TryRead(ref reader, options, PropDetail)) + { + continue; + } + + if (propTokens.TryRead(ref reader, options, PropTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalyzeIndexResponse + { + Detail = propDetail.Value +, + Tokens = propTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalyzeIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetail, value.Detail); + writer.WriteProperty(options, PropTokens, value.Tokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AnalyzeIndexResponseConverter))] public sealed partial class AnalyzeIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("detail")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.AnalyzeDetail? Detail { get; init; } - [JsonInclude, JsonPropertyName("tokens")] public IReadOnlyCollection? Tokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs index 17ef061beb2..31a8903cf42 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ClearCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ClearCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCacheResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCacheResponseConverter))] public sealed partial class ClearCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs index 26696939f0e..27e23c0f6b5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs @@ -18,21 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class CloseIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override CloseIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty> propIndices = default; + LocalJsonProperty propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloseIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Indices = propIndices.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloseIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloseIndexResponseConverter))] public sealed partial class CloseIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.CloseIndexResult))] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs index a52e895259d..202233145dd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class CreateDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CreateDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateDataStreamResponseConverter))] public sealed partial class CreateDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class CreateDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs index 16a1cc6de10..551d3a79f91 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class CreateIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override CreateIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateIndexResponseConverter))] public sealed partial class CreateIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs index 138befc6cfe..57a74e7f8c6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs @@ -18,14 +18,101 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DataStreamsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackingIndices = System.Text.Json.JsonEncodedText.Encode("backing_indices"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreamCount = System.Text.Json.JsonEncodedText.Encode("data_stream_count"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTotalStoreSizeBytes = System.Text.Json.JsonEncodedText.Encode("total_store_size_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropTotalStoreSizes = System.Text.Json.JsonEncodedText.Encode("total_store_sizes"); + + public override DataStreamsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBackingIndices = default; + LocalJsonProperty propDataStreamCount = default; + LocalJsonProperty> propDataStreams = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propTotalStoreSizeBytes = default; + LocalJsonProperty propTotalStoreSizes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryRead(ref reader, options, PropBackingIndices)) + { + continue; + } + + if (propDataStreamCount.TryRead(ref reader, options, PropDataStreamCount)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTotalStoreSizeBytes.TryRead(ref reader, options, PropTotalStoreSizeBytes)) + { + continue; + } + + if (propTotalStoreSizes.TryRead(ref reader, options, PropTotalStoreSizes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataStreamsStatsResponse + { + BackingIndices = propBackingIndices.Value +, + DataStreamCount = propDataStreamCount.Value +, + DataStreams = propDataStreams.Value +, + Shards = propShards.Value +, + TotalStoreSizeBytes = propTotalStoreSizeBytes.Value +, + TotalStoreSizes = propTotalStoreSizes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataStreamsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackingIndices, value.BackingIndices); + writer.WriteProperty(options, PropDataStreamCount, value.DataStreamCount); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTotalStoreSizeBytes, value.TotalStoreSizeBytes); + writer.WriteProperty(options, PropTotalStoreSizes, value.TotalStoreSizes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataStreamsStatsResponseConverter))] public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +120,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total number of backing indices for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("backing_indices")] public int BackingIndices { get; init; } /// @@ -41,7 +127,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total number of selected data streams. /// /// - [JsonInclude, JsonPropertyName("data_stream_count")] public int DataStreamCount { get; init; } /// @@ -49,7 +134,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Contains statistics for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } /// @@ -57,7 +141,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Contains information about shards that attempted to execute the request. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } /// @@ -65,7 +148,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total size, in bytes, of all shards for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("total_store_size_bytes")] public long TotalStoreSizeBytes { get; init; } /// @@ -74,6 +156,5 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// This property is included only if the human query parameter is true /// /// - [JsonInclude, JsonPropertyName("total_store_sizes")] public Elastic.Clients.Elasticsearch.Serverless.ByteSize? TotalStoreSizes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs index befb38314ab..059206cadbd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DeleteAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAliasResponseConverter))] public sealed partial class DeleteAliasResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs index eae7ae00e1b..5bdafc218c0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DeleteDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataLifecycleResponseConverter))] public sealed partial class DeleteDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteDataLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs index 74b889a2db1..cee9d9fe47f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DeleteDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataStreamResponseConverter))] public sealed partial class DeleteDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs index b0aee2bc50b..5350ad83a4f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DeleteIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override DeleteIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexResponseConverter))] public sealed partial class DeleteIndexResponse : ElasticsearchResponse { /// @@ -33,8 +80,6 @@ public sealed partial class DeleteIndexResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs index f90d768e4c0..129f9d0452f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class DeleteIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIndexTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexTemplateResponseConverter))] public sealed partial class DeleteIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteIndexTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs index 00f3c417846..32dc93214af 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs @@ -18,17 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ExplainDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ExplainDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainDataLifecycleResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataLifecycleResponseConverter))] public sealed partial class ExplainDataLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamLifecycleExplain))] public IReadOnlyDictionary Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/FlushResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/FlushResponse.g.cs index 687c6c94df6..5e0a232f53e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/FlushResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/FlushResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class FlushResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override FlushResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FlushResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FlushResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushResponseConverter))] public sealed partial class FlushResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs index a26e677edd8..cb35739739a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ForcemergeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + + public override ForcemergeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propShards = default; + LocalJsonProperty propTask = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForcemergeResponse + { + Shards = propShards.Value +, + Task = propTask.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForcemergeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForcemergeResponseConverter))] public sealed partial class ForcemergeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } /// @@ -37,6 +83,5 @@ public sealed partial class ForcemergeResponse : ElasticsearchResponse /// you can use the task_id to get the status of the task at _tasks/<task_id> /// /// - [JsonInclude, JsonPropertyName("task")] public string? Task { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs index 4a0274cceec..fdc388ebf56 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class GetDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + + public override GetDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataLifecycleResponse + { + DataStreams = propDataStreams.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataLifecycleResponseConverter))] public sealed partial class GetDataLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs index 6ce14db89d9..78466ae599d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class GetDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + + public override GetDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataStreamResponse + { + DataStreams = propDataStreams.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataStreamResponseConverter))] public sealed partial class GetDataStreamResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs index 101331f8170..0ea1d3e677a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class GetIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndexTemplates = System.Text.Json.JsonEncodedText.Encode("index_templates"); + + public override GetIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propIndexTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndexTemplates.TryRead(ref reader, options, PropIndexTemplates)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIndexTemplateResponse + { + IndexTemplates = propIndexTemplates.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndexTemplates, value.IndexTemplates); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIndexTemplateResponseConverter))] public sealed partial class GetIndexTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("index_templates")] public IReadOnlyCollection IndexTemplates { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs index adfc57c3a06..dc2058597f4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class IndicesStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAll = System.Text.Json.JsonEncodedText.Encode("_all"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override IndicesStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAll = default; + LocalJsonProperty?> propIndices = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAll.TryRead(ref reader, options, PropAll)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndicesStatsResponse + { + All = propAll.Value +, + Indices = propIndices.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicesStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAll, value.All); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndicesStatsResponseConverter))] public sealed partial class IndicesStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_all")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndicesStats All { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyDictionary? Indices { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs index 5e5077e08bd..9a501c87b0d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class MigrateToDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override MigrateToDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MigrateToDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MigrateToDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MigrateToDataStreamResponseConverter))] public sealed partial class MigrateToDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class MigrateToDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs index 70e5ef0f6a2..c2963136bb7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ModifyDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ModifyDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ModifyDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ModifyDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ModifyDataStreamResponseConverter))] public sealed partial class ModifyDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ModifyDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs index 196b23e35d7..ca03dcda83e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class OpenIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override OpenIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenIndexResponse + { + Acknowledged = propAcknowledged.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenIndexResponseConverter))] public sealed partial class OpenIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutAliasResponse.g.cs index f22ac858682..dea9ad11f21 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutAliasResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class PutAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutAliasResponseConverter))] public sealed partial class PutAliasResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs index 39f545869db..1782b443e23 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs @@ -65,7 +65,7 @@ public sealed partial class PutDataLifecycleRequestParameters : RequestParameter /// Update the data stream lifecycle of the specified data streams. /// /// -public sealed partial class PutDataLifecycleRequest : PlainRequest, ISelfSerializable +public sealed partial class PutDataLifecycleRequest : PlainRequest, ISelfTwoWaySerializable { public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.Serverless.DataStreamNames name) : base(r => r.Required("name", name)) { @@ -107,13 +107,17 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.Serverless.DataStre /// [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamLifecycle Lifecycle { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Lifecycle, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Lifecycle = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs index 633a0f789a7..648420c9955 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class PutDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDataLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDataLifecycleResponseConverter))] public sealed partial class PutDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutDataLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs index 0296d8cd3c5..d06f26f7352 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class PutIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIndexTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndexTemplateResponseConverter))] public sealed partial class PutIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutIndexTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file 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 11aab97f1e4..e6c83ba2262 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 @@ -114,7 +114,7 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet /// To change the analyzer for existing backing indices, you must create a new data stream and reindex your data into it. /// /// -public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfSerializable +public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfTwoWaySerializable { public PutIndicesSettingsRequest() { @@ -197,13 +197,17 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Serverless.Indice /// [JsonIgnore] 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) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Settings, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Settings = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs index bf6e6f4e7ae..a9e9fd4132c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class PutIndicesSettingsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIndicesSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIndicesSettingsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIndicesSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndicesSettingsResponseConverter))] public sealed partial class PutIndicesSettingsResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutIndicesSettingsResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingRequest.g.cs index ea4d3ac7b6a..3d354c34019 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -81,6 +82,139 @@ public sealed partial class PutMappingRequestParameters : RequestParameters public bool? WriteIndexOnly { get => Q("write_index_only"); set => Q("write_index_only", value); } } +internal sealed partial class PutMappingRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDateDetection = System.Text.Json.JsonEncodedText.Encode("date_detection"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropDynamicDateFormats = System.Text.Json.JsonEncodedText.Encode("dynamic_date_formats"); + private static readonly System.Text.Json.JsonEncodedText PropDynamicTemplates = System.Text.Json.JsonEncodedText.Encode("dynamic_templates"); + private static readonly System.Text.Json.JsonEncodedText PropFieldNames = System.Text.Json.JsonEncodedText.Encode("_field_names"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropNumericDetection = System.Text.Json.JsonEncodedText.Encode("numeric_detection"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override PutMappingRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDateDetection = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty?> propDynamicDateFormats = default; + LocalJsonProperty>?> propDynamicTemplates = default; + LocalJsonProperty propFieldNames = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNumericDetection = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty?> propRuntime = default; + LocalJsonProperty propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDateDetection.TryRead(ref reader, options, PropDateDetection)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propDynamicDateFormats.TryRead(ref reader, options, PropDynamicDateFormats)) + { + continue; + } + + if (propDynamicTemplates.TryRead(ref reader, options, PropDynamicTemplates, typeof(SingleOrManyMarker>?, IReadOnlyDictionary>))) + { + continue; + } + + if (propFieldNames.TryRead(ref reader, options, PropFieldNames)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNumericDetection.TryRead(ref reader, options, PropNumericDetection)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propRuntime.TryRead(ref reader, options, PropRuntime)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutMappingRequest + { + DateDetection = propDateDetection.Value + , + Dynamic = propDynamic.Value + , + DynamicDateFormats = propDynamicDateFormats.Value + , + DynamicTemplates = propDynamicTemplates.Value + , + FieldNames = propFieldNames.Value + , + Meta = propMeta.Value + , + NumericDetection = propNumericDetection.Value + , + Properties = propProperties.Value + , + Routing = propRouting.Value + , + Runtime = propRuntime.Value + , + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutMappingRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDateDetection, value.DateDetection); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropDynamicDateFormats, value.DynamicDateFormats); + writer.WriteProperty(options, PropDynamicTemplates, value.DynamicTemplates, typeof(SingleOrManyMarker>?, IReadOnlyDictionary>)); + writer.WriteProperty(options, PropFieldNames, value.FieldNames); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNumericDetection, value.NumericDetection); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropRuntime, value.Runtime); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteEndObject(); + } +} + /// /// /// Update field mappings. @@ -123,6 +257,7 @@ public sealed partial class PutMappingRequestParameters : RequestParameters /// Instead, add an alias field to create an alternate field name. /// /// +[JsonConverter(typeof(PutMappingRequestConverter))] public sealed partial class PutMappingRequest : PlainRequest { public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices) : base(r => r.Required("index", indices)) @@ -143,7 +278,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// This behavior applies even if the request targets other open indices. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -154,7 +288,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Valid values are: all, open, closed, hidden, none. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -162,7 +295,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// If false, the request returns an error if it targets a missing or closed index. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -171,7 +303,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -180,7 +311,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -188,7 +318,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// If true, the mappings are applied only to the current write index for the target. /// /// - [JsonIgnore] public bool? WriteIndexOnly { get => Q("write_index_only"); set => Q("write_index_only", value); } /// @@ -196,7 +325,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Controls whether dynamic date detection is enabled. /// /// - [JsonInclude, JsonPropertyName("date_detection")] public bool? DateDetection { get; set; } /// @@ -204,7 +332,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Controls whether new fields are added dynamically. /// /// - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } /// @@ -214,7 +341,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// a new date field is added instead of string. /// /// - [JsonInclude, JsonPropertyName("dynamic_date_formats")] public ICollection? DynamicDateFormats { get; set; } /// @@ -222,8 +348,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Specify dynamic templates for the mapping. /// /// - [JsonInclude, JsonPropertyName("dynamic_templates")] - [SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary))] public ICollection>? DynamicTemplates { get; set; } /// @@ -231,7 +355,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Control whether field names are enabled for the index. /// /// - [JsonInclude, JsonPropertyName("_field_names")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.FieldNamesField? FieldNames { get; set; } /// @@ -241,7 +364,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// application-specific metadata. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IDictionary? Meta { get; set; } /// @@ -249,7 +371,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Automatically map strings into numeric data types for all fields. /// /// - [JsonInclude, JsonPropertyName("numeric_detection")] public bool? NumericDetection { get; set; } /// @@ -274,7 +395,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// /// /// - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } /// @@ -282,7 +402,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Enable making a routing value required on indexed documents. /// /// - [JsonInclude, JsonPropertyName("_routing")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.RoutingField? Routing { get; set; } /// @@ -290,7 +409,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Mapping of runtime fields for the index. /// /// - [JsonInclude, JsonPropertyName("runtime")] public IDictionary? Runtime { get; set; } /// @@ -298,7 +416,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indice /// Control whether the _source field is enabled on the index. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.SourceField? Source { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingResponse.g.cs index 3e6986a7ede..06b3a83a5b9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/PutMappingResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class PutMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override PutMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutMappingResponse + { + Acknowledged = propAcknowledged.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutMappingResponseConverter))] public sealed partial class PutMappingResponse : ElasticsearchResponse { /// @@ -33,8 +80,6 @@ public sealed partial class PutMappingResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RefreshResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RefreshResponse.g.cs index 52956bca56e..5bd554b18de 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RefreshResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RefreshResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class RefreshResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override RefreshResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RefreshResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RefreshResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RefreshResponseConverter))] public sealed partial class RefreshResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs index ec8b5501790..3d51583838e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ResolveIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ResolveIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propAliases = default; + LocalJsonProperty> propDataStreams = default; + LocalJsonProperty> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAliases.TryRead(ref reader, options, PropAliases)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexResponse + { + Aliases = propAliases.Value +, + DataStreams = propDataStreams.Value +, + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAliases, value.Aliases); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexResponseConverter))] public sealed partial class ResolveIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aliases")] public IReadOnlyCollection Aliases { get; init; } - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RolloverResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RolloverResponse.g.cs index ffdebd2dbda..5f0d86aafe9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RolloverResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/RolloverResponse.g.cs @@ -18,28 +18,118 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class RolloverResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropConditions = System.Text.Json.JsonEncodedText.Encode("conditions"); + private static readonly System.Text.Json.JsonEncodedText PropDryRun = System.Text.Json.JsonEncodedText.Encode("dry_run"); + private static readonly System.Text.Json.JsonEncodedText PropNewIndex = System.Text.Json.JsonEncodedText.Encode("new_index"); + private static readonly System.Text.Json.JsonEncodedText PropOldIndex = System.Text.Json.JsonEncodedText.Encode("old_index"); + private static readonly System.Text.Json.JsonEncodedText PropRolledOver = System.Text.Json.JsonEncodedText.Encode("rolled_over"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override RolloverResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty> propConditions = default; + LocalJsonProperty propDryRun = default; + LocalJsonProperty propNewIndex = default; + LocalJsonProperty propOldIndex = default; + LocalJsonProperty propRolledOver = default; + LocalJsonProperty propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propConditions.TryRead(ref reader, options, PropConditions)) + { + continue; + } + + if (propDryRun.TryRead(ref reader, options, PropDryRun)) + { + continue; + } + + if (propNewIndex.TryRead(ref reader, options, PropNewIndex)) + { + continue; + } + + if (propOldIndex.TryRead(ref reader, options, PropOldIndex)) + { + continue; + } + + if (propRolledOver.TryRead(ref reader, options, PropRolledOver)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RolloverResponse + { + Acknowledged = propAcknowledged.Value +, + Conditions = propConditions.Value +, + DryRun = propDryRun.Value +, + NewIndex = propNewIndex.Value +, + OldIndex = propOldIndex.Value +, + RolledOver = propRolledOver.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RolloverResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropConditions, value.Conditions); + writer.WriteProperty(options, PropDryRun, value.DryRun); + writer.WriteProperty(options, PropNewIndex, value.NewIndex); + writer.WriteProperty(options, PropOldIndex, value.OldIndex); + writer.WriteProperty(options, PropRolledOver, value.RolledOver); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RolloverResponseConverter))] public sealed partial class RolloverResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("conditions")] public IReadOnlyDictionary Conditions { get; init; } - [JsonInclude, JsonPropertyName("dry_run")] public bool DryRun { get; init; } - [JsonInclude, JsonPropertyName("new_index")] public string NewIndex { get; init; } - [JsonInclude, JsonPropertyName("old_index")] public string OldIndex { get; init; } - [JsonInclude, JsonPropertyName("rolled_over")] public bool RolledOver { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SegmentsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SegmentsResponse.g.cs index a013b743050..0517e2c3a65 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SegmentsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SegmentsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class SegmentsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override SegmentsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propIndices = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SegmentsResponse + { + Indices = propIndices.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SegmentsResponseConverter))] public sealed partial class SegmentsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs index d5f4ab63e53..142801a9f9b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class SimulateIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + + public override SimulateIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propOverlapping = default; + LocalJsonProperty propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryRead(ref reader, options, PropOverlapping)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateIndexTemplateResponse + { + Overlapping = propOverlapping.Value +, + Template = propTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOverlapping, value.Overlapping); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateIndexTemplateResponseConverter))] public sealed partial class SimulateIndexTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("overlapping")] public IReadOnlyCollection? Overlapping { get; init; } - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs index 2cc6cb2844c..3a117cd0dbb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class SimulateTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + + public override SimulateTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propOverlapping = default; + LocalJsonProperty propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryRead(ref reader, options, PropOverlapping)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateTemplateResponse + { + Overlapping = propOverlapping.Value +, + Template = propTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOverlapping, value.Overlapping); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateTemplateResponseConverter))] public sealed partial class SimulateTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("overlapping")] public IReadOnlyCollection? Overlapping { get; init; } - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs index cca0075dcba..c18e16d3737 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class UpdateAliasesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UpdateAliasesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateAliasesResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateAliasesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateAliasesResponseConverter))] public sealed partial class UpdateAliasesResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class UpdateAliasesResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs index 6d138d626de..8ad7cd97213 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs @@ -18,22 +18,85 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ValidateQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropError = System.Text.Json.JsonEncodedText.Encode("error"); + private static readonly System.Text.Json.JsonEncodedText PropExplanations = System.Text.Json.JsonEncodedText.Encode("explanations"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropValid = System.Text.Json.JsonEncodedText.Encode("valid"); + + public override ValidateQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propError = default; + LocalJsonProperty?> propExplanations = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propValid = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propError.TryRead(ref reader, options, PropError)) + { + continue; + } + + if (propExplanations.TryRead(ref reader, options, PropExplanations)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propValid.TryRead(ref reader, options, PropValid)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateQueryResponse + { + Error = propError.Value +, + Explanations = propExplanations.Value +, + Shards = propShards.Value +, + Valid = propValid.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropError, value.Error); + writer.WriteProperty(options, PropExplanations, value.Explanations); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropValid, value.Valid); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateQueryResponseConverter))] public sealed partial class ValidateQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error")] public string? Error { get; init; } - [JsonInclude, JsonPropertyName("explanations")] public IReadOnlyCollection? Explanations { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics? Shards { get; init; } - [JsonInclude, JsonPropertyName("valid")] public bool Valid { get; init; } } \ No newline at end of file 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 de8f1f2caf9..49cabe29d25 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexRequest.g.cs @@ -127,7 +127,7 @@ public sealed partial class IndexRequestParameters : RequestParameters /// 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, ISelfSerializable +public sealed partial class IndexRequest : PlainRequest, ISelfTwoWaySerializable { public IndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id? id) : base(r => r.Required("index", index).Optional("id", id)) { @@ -242,13 +242,17 @@ public IndexRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index) : /// [JsonIgnore] 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) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { settings.SourceSerializer.Serialize(Document, writer); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Document = settings.SourceSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexResponse.g.cs index ce056a65bd4..37b968a3e03 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/IndexResponse.g.cs @@ -18,30 +18,129 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class IndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override IndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propForcedRefresh = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propResult = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexResponseConverter))] public sealed partial class IndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/DeleteInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/DeleteInferenceResponse.g.cs index 87912c59bf7..9fdb1508ef9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/DeleteInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/DeleteInferenceResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Inference; +internal sealed partial class DeleteInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropPipelines = System.Text.Json.JsonEncodedText.Encode("pipelines"); + + public override DeleteInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty> propPipelines = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propPipelines.TryRead(ref reader, options, PropPipelines)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteInferenceResponse + { + Acknowledged = propAcknowledged.Value +, + Pipelines = propPipelines.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropPipelines, value.Pipelines); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteInferenceResponseConverter))] public sealed partial class DeleteInferenceResponse : ElasticsearchResponse { /// @@ -33,8 +80,6 @@ public sealed partial class DeleteInferenceResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("pipelines")] public IReadOnlyCollection Pipelines { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/GetInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/GetInferenceResponse.g.cs index eadcef93ac5..ea45b0380a5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/GetInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/GetInferenceResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Inference; +internal sealed partial class GetInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEndpoints = System.Text.Json.JsonEncodedText.Encode("endpoints"); + + public override GetInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propEndpoints = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEndpoints.TryRead(ref reader, options, PropEndpoints)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetInferenceResponse + { + Endpoints = propEndpoints.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEndpoints, value.Endpoints); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetInferenceResponseConverter))] public sealed partial class GetInferenceResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("endpoints")] public IReadOnlyCollection Endpoints { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceRequest.g.cs index 6e94c6b33af..34bd4a76f2f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -40,11 +41,65 @@ public sealed partial class InferenceRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } } +internal sealed partial class InferenceRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInput = System.Text.Json.JsonEncodedText.Encode("input"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropTaskSettings = System.Text.Json.JsonEncodedText.Encode("task_settings"); + + public override InferenceRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propInput = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propTaskSettings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInput.TryRead(ref reader, options, PropInput, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propTaskSettings.TryRead(ref reader, options, PropTaskSettings)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceRequest + { + Input = propInput.Value + , + Query = propQuery.Value + , + TaskSettings = propTaskSettings.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInput, value.Input, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings); + writer.WriteEndObject(); + } +} + /// /// /// Perform inference on the service /// /// +[JsonConverter(typeof(InferenceRequestConverter))] public sealed partial class InferenceRequest : PlainRequest { public InferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) @@ -68,7 +123,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Inference.TaskT /// Specifies the amount of time to wait for the inference request to complete. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -77,8 +131,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Inference.TaskT /// Either a string or an array of strings. /// /// - [JsonInclude, JsonPropertyName("input")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection Input { get; set; } /// @@ -87,7 +139,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Inference.TaskT /// Not required for other tasks. /// /// - [JsonInclude, JsonPropertyName("query")] public string? Query { get; set; } /// @@ -95,7 +146,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Inference.TaskT /// Optional task settings /// /// - [JsonInclude, JsonPropertyName("task_settings")] public object? TaskSettings { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceResponse.g.cs index 0e2891aecf9..8a2e32ff84c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/InferenceResponse.g.cs @@ -18,14 +18,39 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Inference; +internal sealed partial class InferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override InferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferenceResponseConverter))] public sealed partial class InferenceResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceRequest.g.cs index eadac2de1ea..9bb8e6bde28 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceRequest.g.cs @@ -49,7 +49,7 @@ public sealed partial class PutInferenceRequestParameters : RequestParameters /// However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs. /// /// -public sealed partial class PutInferenceRequest : PlainRequest, ISelfSerializable +public sealed partial class PutInferenceRequest : PlainRequest, ISelfTwoWaySerializable { public PutInferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) { @@ -67,13 +67,17 @@ public PutInferenceRequest(Elastic.Clients.Elasticsearch.Serverless.Inference.Ta internal override string OperationName => "inference.put"; - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Inference.InferenceEndpoint InferenceConfig { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, InferenceConfig, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + InferenceConfig = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceResponse.g.cs index 88c831242f4..c8386e18463 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Inference/PutInferenceResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Inference; +internal sealed partial class PutInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInferenceId = System.Text.Json.JsonEncodedText.Encode("inference_id"); + private static readonly System.Text.Json.JsonEncodedText PropService = System.Text.Json.JsonEncodedText.Encode("service"); + private static readonly System.Text.Json.JsonEncodedText PropServiceSettings = System.Text.Json.JsonEncodedText.Encode("service_settings"); + private static readonly System.Text.Json.JsonEncodedText PropTaskSettings = System.Text.Json.JsonEncodedText.Encode("task_settings"); + private static readonly System.Text.Json.JsonEncodedText PropTaskType = System.Text.Json.JsonEncodedText.Encode("task_type"); + + public override PutInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propInferenceId = default; + LocalJsonProperty propService = default; + LocalJsonProperty propServiceSettings = default; + LocalJsonProperty propTaskSettings = default; + LocalJsonProperty propTaskType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceId.TryRead(ref reader, options, PropInferenceId)) + { + continue; + } + + if (propService.TryRead(ref reader, options, PropService)) + { + continue; + } + + if (propServiceSettings.TryRead(ref reader, options, PropServiceSettings)) + { + continue; + } + + if (propTaskSettings.TryRead(ref reader, options, PropTaskSettings)) + { + continue; + } + + if (propTaskType.TryRead(ref reader, options, PropTaskType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutInferenceResponse + { + InferenceId = propInferenceId.Value +, + Service = propService.Value +, + ServiceSettings = propServiceSettings.Value +, + TaskSettings = propTaskSettings.Value +, + TaskType = propTaskType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInferenceId, value.InferenceId); + writer.WriteProperty(options, PropService, value.Service); + writer.WriteProperty(options, PropServiceSettings, value.ServiceSettings); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings); + writer.WriteProperty(options, PropTaskType, value.TaskType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutInferenceResponseConverter))] public sealed partial class PutInferenceResponse : ElasticsearchResponse { /// @@ -33,7 +110,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The inference Id /// /// - [JsonInclude, JsonPropertyName("inference_id")] public string InferenceId { get; init; } /// @@ -41,7 +117,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The service type /// /// - [JsonInclude, JsonPropertyName("service")] public string Service { get; init; } /// @@ -49,7 +124,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// Settings specific to the service /// /// - [JsonInclude, JsonPropertyName("service_settings")] public object ServiceSettings { get; init; } /// @@ -57,7 +131,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// Task settings specific to the service and task type /// /// - [JsonInclude, JsonPropertyName("task_settings")] public object? TaskSettings { get; init; } /// @@ -65,6 +138,5 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The task type /// /// - [JsonInclude, JsonPropertyName("task_type")] public Elastic.Clients.Elasticsearch.Serverless.Inference.TaskType TaskType { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/InfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/InfoResponse.g.cs index ea3e2509507..2760e3b01fd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/InfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/InfoResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class InfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropClusterUuid = System.Text.Json.JsonEncodedText.Encode("cluster_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropTagline = System.Text.Json.JsonEncodedText.Encode("tagline"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override InfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty propClusterUuid = default; + LocalJsonProperty propName = default; + LocalJsonProperty propTagline = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propClusterUuid.TryRead(ref reader, options, PropClusterUuid)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propTagline.TryRead(ref reader, options, PropTagline)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InfoResponse + { + ClusterName = propClusterName.Value +, + ClusterUuid = propClusterUuid.Value +, + Name = propName.Value +, + Tagline = propTagline.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropTagline, value.Tagline); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InfoResponseConverter))] public sealed partial class InfoResponse : ElasticsearchResponse { /// @@ -33,9 +110,7 @@ public sealed partial class InfoResponse : ElasticsearchResponse /// The responding cluster's name. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } /// @@ -43,9 +118,7 @@ public sealed partial class InfoResponse : ElasticsearchResponse /// The responding node's name. /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } - [JsonInclude, JsonPropertyName("tagline")] public string Tagline { get; init; } /// @@ -53,6 +126,5 @@ public sealed partial class InfoResponse : ElasticsearchResponse /// The running version of Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("version")] public Elastic.Clients.Elasticsearch.Serverless.ElasticsearchVersionInfo Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs index d25a7acde05..4cb6ddd45f3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class DeleteGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteGeoipDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteGeoipDatabaseResponseConverter))] public sealed partial class DeleteGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteGeoipDatabaseResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs index faadfbc99b4..a24bbc0d53d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class DeleteIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIpLocationDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIpLocationDatabaseResponseConverter))] public sealed partial class DeleteIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteIpLocationDatabaseResponse : ElasticsearchResp /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeletePipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeletePipelineResponse.g.cs index a607d2fedf7..bf41b4b2e47 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeletePipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/DeletePipelineResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class DeletePipelineResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeletePipelineResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeletePipelineResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeletePipelineResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePipelineResponseConverter))] public sealed partial class DeletePipelineResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeletePipelineResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs index cf6f1342cd0..a96028ea986 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class GeoIpStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + + public override GeoIpStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propNodes = default; + LocalJsonProperty propStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoIpStatsResponse + { + Nodes = propNodes.Value +, + Stats = propStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoIpStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoIpStatsResponseConverter))] public sealed partial class GeoIpStatsResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Downloaded GeoIP2 databases for each node. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Download statistics for all GeoIP2 databases. /// /// - [JsonInclude, JsonPropertyName("stats")] public Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpDownloadStatistics Stats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs index 92e10c2b774..446f5746d09 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class GetGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDatabases = System.Text.Json.JsonEncodedText.Encode("databases"); + + public override GetGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryRead(ref reader, options, PropDatabases)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetGeoipDatabaseResponse + { + Databases = propDatabases.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDatabases, value.Databases); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetGeoipDatabaseResponseConverter))] public sealed partial class GetGeoipDatabaseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("databases")] public IReadOnlyCollection Databases { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs index 3413683d5e0..3552d01e850 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class GetIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDatabases = System.Text.Json.JsonEncodedText.Encode("databases"); + + public override GetIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryRead(ref reader, options, PropDatabases)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIpLocationDatabaseResponse + { + Databases = propDatabases.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDatabases, value.Databases); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIpLocationDatabaseResponseConverter))] public sealed partial class GetIpLocationDatabaseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("databases")] public IReadOnlyCollection Databases { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs index ec998cacb5b..ea008f3d1cd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class ProcessorGrokResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPatterns = System.Text.Json.JsonEncodedText.Encode("patterns"); + + public override ProcessorGrokResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propPatterns = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPatterns.TryRead(ref reader, options, PropPatterns)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ProcessorGrokResponse + { + Patterns = propPatterns.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ProcessorGrokResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPatterns, value.Patterns); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ProcessorGrokResponseConverter))] public sealed partial class ProcessorGrokResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("patterns")] public IReadOnlyDictionary Patterns { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs index c098d37a2a9..24065342334 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class PutGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutGeoipDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutGeoipDatabaseResponseConverter))] public sealed partial class PutGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutGeoipDatabaseResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs index 8f337335f24..e2701cad8bb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs @@ -56,7 +56,7 @@ public sealed partial class PutIpLocationDatabaseRequestParameters : RequestPara /// Create or update an IP geolocation database configuration. /// /// -public sealed partial class PutIpLocationDatabaseRequest : PlainRequest, ISelfSerializable +public sealed partial class PutIpLocationDatabaseRequest : PlainRequest, ISelfTwoWaySerializable { public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Serverless.Id id) : base(r => r.Required("id", id)) { @@ -89,13 +89,17 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Serverless.Id /// [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Ingest.DatabaseConfiguration Configuration { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Configuration, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Configuration = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs index 3f5f8d048f0..cc2ba7ed95f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class PutIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIpLocationDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIpLocationDatabaseResponseConverter))] public sealed partial class PutIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutIpLocationDatabaseResponse : ElasticsearchRespons /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutPipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutPipelineResponse.g.cs index 1e248573d0c..6ab2e45c21b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutPipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/PutPipelineResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class PutPipelineResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutPipelineResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutPipelineResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutPipelineResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPipelineResponseConverter))] public sealed partial class PutPipelineResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutPipelineResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/SimulateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/SimulateResponse.g.cs index ce9751221ea..6622099c75c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/SimulateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Ingest/SimulateResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class SimulateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override SimulateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateResponseConverter))] public sealed partial class SimulateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs index 8fa51607bf7..17bc4b01ac7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.LicenseManagement; +internal sealed partial class GetLicenseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLicense = System.Text.Json.JsonEncodedText.Encode("license"); + + public override GetLicenseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLicense = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLicense.TryRead(ref reader, options, PropLicense)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetLicenseResponse + { + License = propLicense.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetLicenseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLicense, value.License); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetLicenseResponseConverter))] public sealed partial class GetLicenseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.Serverless.LicenseManagement.LicenseInformation License { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs index 85eda28ed17..481d057e286 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ClearTrainedModelDeploymentCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCleared = System.Text.Json.JsonEncodedText.Encode("cleared"); + + public override ClearTrainedModelDeploymentCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCleared = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCleared.TryRead(ref reader, options, PropCleared)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearTrainedModelDeploymentCacheResponse + { + Cleared = propCleared.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearTrainedModelDeploymentCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCleared, value.Cleared); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearTrainedModelDeploymentCacheResponseConverter))] public sealed partial class ClearTrainedModelDeploymentCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cleared")] public bool Cleared { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/CloseJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/CloseJobResponse.g.cs index 77e3416af09..3573a0cc572 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/CloseJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/CloseJobResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class CloseJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + + public override CloseJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClosed = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClosed.TryRead(ref reader, options, PropClosed)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloseJobResponse + { + Closed = propClosed.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloseJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClosed, value.Closed); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloseJobResponseConverter))] public sealed partial class CloseJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("closed")] public bool Closed { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs index f71ba556930..24a88b47834 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteCalendarEventResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteCalendarEventResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarEventResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarEventResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarEventResponseConverter))] public sealed partial class DeleteCalendarEventResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteCalendarEventResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs index 93f5a7e4768..bdc40917638 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteCalendarJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override DeleteCalendarJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCalendarId = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarJobResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarJobResponseConverter))] public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +104,5 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs index e52c9343723..4533f9a5f6c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteCalendarResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteCalendarResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarResponseConverter))] public sealed partial class DeleteCalendarResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteCalendarResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs index 25d09960c32..79fa6c5faa0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataFrameAnalyticsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataFrameAnalyticsResponseConverter))] public sealed partial class DeleteDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteDataFrameAnalyticsResponse : ElasticsearchResp /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs index 82dcab69bde..bcd7fba4bd6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDatafeedResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDatafeedResponseConverter))] public sealed partial class DeleteDatafeedResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteDatafeedResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs index 08048c0922c..89ed2cba300 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteExpiredDataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + + public override DeleteExpiredDataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDeleted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteExpiredDataResponse + { + Deleted = propDeleted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteExpiredDataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteExpiredDataResponseConverter))] public sealed partial class DeleteExpiredDataResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("deleted")] public bool Deleted { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs index 1cfbc6d6b8b..a1c0a3f6aad 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteFilterResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteFilterResponseConverter))] public sealed partial class DeleteFilterResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteFilterResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs index f2d0e1be4df..3af1c17d4bb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteForecastResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteForecastResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteForecastResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteForecastResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteForecastResponseConverter))] public sealed partial class DeleteForecastResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteForecastResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs index eaba9314e44..d6f118e9b7b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteJobResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteJobResponseConverter))] public sealed partial class DeleteJobResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteJobResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs index 4dcd0a28b87..d076534ac84 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteModelSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteModelSnapshotResponseConverter))] public sealed partial class DeleteModelSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteModelSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs index 77efa89d63c..a128791f79c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteTrainedModelAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTrainedModelAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTrainedModelAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTrainedModelAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelAliasResponseConverter))] public sealed partial class DeleteTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteTrainedModelAliasResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs index 6afafbd30f8..8a4afea243e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DeleteTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTrainedModelResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelResponseConverter))] public sealed partial class DeleteTrainedModelResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteTrainedModelResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs index 922869af4c3..9915b50cf5b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class EstimateModelMemoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryEstimate = System.Text.Json.JsonEncodedText.Encode("model_memory_estimate"); + + public override EstimateModelMemoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propModelMemoryEstimate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModelMemoryEstimate.TryRead(ref reader, options, PropModelMemoryEstimate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EstimateModelMemoryResponse + { + ModelMemoryEstimate = propModelMemoryEstimate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EstimateModelMemoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropModelMemoryEstimate, value.ModelMemoryEstimate); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EstimateModelMemoryResponseConverter))] public sealed partial class EstimateModelMemoryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("model_memory_estimate")] public string ModelMemoryEstimate { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs index 29141cbaa77..4ca70747b7e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class EvaluateDataFrameResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText PropOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText PropRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + + public override EvaluateDataFrameResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClassification = default; + LocalJsonProperty propOutlierDetection = default; + LocalJsonProperty propRegression = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClassification.TryRead(ref reader, options, PropClassification)) + { + continue; + } + + if (propOutlierDetection.TryRead(ref reader, options, PropOutlierDetection)) + { + continue; + } + + if (propRegression.TryRead(ref reader, options, PropRegression)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EvaluateDataFrameResponse + { + Classification = propClassification.Value +, + OutlierDetection = propOutlierDetection.Value +, + Regression = propRegression.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EvaluateDataFrameResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClassification, value.Classification); + writer.WriteProperty(options, PropOutlierDetection, value.OutlierDetection); + writer.WriteProperty(options, PropRegression, value.Regression); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EvaluateDataFrameResponseConverter))] public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse { /// @@ -34,7 +91,6 @@ public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse /// It outputs a prediction that identifies to which of the classes each document belongs. /// /// - [JsonInclude, JsonPropertyName("classification")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeClassificationSummary? Classification { get; init; } /// @@ -43,7 +99,6 @@ public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse /// It outputs the probability that each document is an outlier. /// /// - [JsonInclude, JsonPropertyName("outlier_detection")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeOutlierDetectionSummary? OutlierDetection { get; init; } /// @@ -51,6 +106,5 @@ public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse /// Evaluation results for a regression analysis which outputs a prediction of values. /// /// - [JsonInclude, JsonPropertyName("regression")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeRegressionSummary? Regression { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs index a6c84a58c69..d2398cc1a85 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ExplainDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFieldSelection = System.Text.Json.JsonEncodedText.Encode("field_selection"); + private static readonly System.Text.Json.JsonEncodedText PropMemoryEstimation = System.Text.Json.JsonEncodedText.Encode("memory_estimation"); + + public override ExplainDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propFieldSelection = default; + LocalJsonProperty propMemoryEstimation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFieldSelection.TryRead(ref reader, options, PropFieldSelection)) + { + continue; + } + + if (propMemoryEstimation.TryRead(ref reader, options, PropMemoryEstimation)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainDataFrameAnalyticsResponse + { + FieldSelection = propFieldSelection.Value +, + MemoryEstimation = propMemoryEstimation.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFieldSelection, value.FieldSelection); + writer.WriteProperty(options, PropMemoryEstimation, value.MemoryEstimation); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataFrameAnalyticsResponseConverter))] public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that explain selection for each field, sorted by the field names. /// /// - [JsonInclude, JsonPropertyName("field_selection")] public IReadOnlyCollection FieldSelection { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that explain selection for each field, sorted by the field names. /// /// - [JsonInclude, JsonPropertyName("memory_estimation")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsMemoryEstimation MemoryEstimation { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/FlushJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/FlushJobResponse.g.cs index 153a31d6ccb..5df944eb7a6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/FlushJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/FlushJobResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class FlushJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFlushed = System.Text.Json.JsonEncodedText.Encode("flushed"); + private static readonly System.Text.Json.JsonEncodedText PropLastFinalizedBucketEnd = System.Text.Json.JsonEncodedText.Encode("last_finalized_bucket_end"); + + public override FlushJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFlushed = default; + LocalJsonProperty propLastFinalizedBucketEnd = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlushed.TryRead(ref reader, options, PropFlushed)) + { + continue; + } + + if (propLastFinalizedBucketEnd.TryRead(ref reader, options, PropLastFinalizedBucketEnd)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FlushJobResponse + { + Flushed = propFlushed.Value +, + LastFinalizedBucketEnd = propLastFinalizedBucketEnd.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FlushJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFlushed, value.Flushed); + writer.WriteProperty(options, PropLastFinalizedBucketEnd, value.LastFinalizedBucketEnd); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushJobResponseConverter))] public sealed partial class FlushJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("flushed")] public bool Flushed { get; init; } /// @@ -37,6 +83,5 @@ public sealed partial class FlushJobResponse : ElasticsearchResponse /// the last bucket that was processed. /// /// - [JsonInclude, JsonPropertyName("last_finalized_bucket_end")] public int? LastFinalizedBucketEnd { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ForecastResponse.g.cs index 1e1980755b1..886249ef23d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ForecastResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ForecastResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropForecastId = System.Text.Json.JsonEncodedText.Encode("forecast_id"); + + public override ForecastResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propForecastId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propForecastId.TryRead(ref reader, options, PropForecastId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForecastResponse + { + Acknowledged = propAcknowledged.Value +, + ForecastId = propForecastId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForecastResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropForecastId, value.ForecastId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForecastResponseConverter))] public sealed partial class ForecastResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("forecast_id")] public string ForecastId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs index 39a5dfa7a94..88eac819299 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetBucketsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBuckets = System.Text.Json.JsonEncodedText.Encode("buckets"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetBucketsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propBuckets = default; + LocalJsonProperty propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuckets.TryRead(ref reader, options, PropBuckets)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBucketsResponse + { + Buckets = propBuckets.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBucketsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBuckets, value.Buckets); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBucketsResponseConverter))] public sealed partial class GetBucketsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("buckets")] public IReadOnlyCollection Buckets { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs index e283a01a1d2..a09cba9e51b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetCalendarEventsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + + public override GetCalendarEventsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCalendarEventsResponse + { + Count = propCount.Value +, + Events = propEvents.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCalendarEventsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCalendarEventsResponseConverter))] public sealed partial class GetCalendarEventsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection Events { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs index afda50d69dd..6ab9a795284 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetCalendarsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendars = System.Text.Json.JsonEncodedText.Encode("calendars"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetCalendarsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propCalendars = default; + LocalJsonProperty propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendars.TryRead(ref reader, options, PropCalendars)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCalendarsResponse + { + Calendars = propCalendars.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCalendarsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendars, value.Calendars); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCalendarsResponseConverter))] public sealed partial class GetCalendarsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("calendars")] public IReadOnlyCollection Calendars { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs index 024ea36bf85..5e299be4e78 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetCategoriesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCategories = System.Text.Json.JsonEncodedText.Encode("categories"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetCategoriesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propCategories = default; + LocalJsonProperty propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCategories.TryRead(ref reader, options, PropCategories)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCategoriesResponse + { + Categories = propCategories.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCategoriesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCategories, value.Categories); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCategoriesResponseConverter))] public sealed partial class GetCategoriesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("categories")] public IReadOnlyCollection Categories { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs index 42dc76a3e59..c1ebf50cc2a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrameAnalytics = System.Text.Json.JsonEncodedText.Encode("data_frame_analytics"); + + public override GetDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDataFrameAnalytics.TryRead(ref reader, options, PropDataFrameAnalytics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataFrameAnalyticsResponse + { + Count = propCount.Value +, + DataFrameAnalytics = propDataFrameAnalytics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsResponseConverter))] public sealed partial class GetDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class GetDataFrameAnalyticsResponse : ElasticsearchRespons /// An array of data frame analytics job resources, which are sorted by the id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("data_frame_analytics")] public IReadOnlyCollection DataFrameAnalytics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs index 771939f5968..c35bed6d8fc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetDataFrameAnalyticsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrameAnalytics = System.Text.Json.JsonEncodedText.Encode("data_frame_analytics"); + + public override GetDataFrameAnalyticsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDataFrameAnalytics.TryRead(ref reader, options, PropDataFrameAnalytics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataFrameAnalyticsStatsResponse + { + Count = propCount.Value +, + DataFrameAnalytics = propDataFrameAnalytics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataFrameAnalyticsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsStatsResponseConverter))] public sealed partial class GetDataFrameAnalyticsStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class GetDataFrameAnalyticsStatsResponse : ElasticsearchRe /// An array of objects that contain usage information for data frame analytics jobs, which are sorted by the id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("data_frame_analytics")] public IReadOnlyCollection DataFrameAnalytics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs index cc43d913335..81149391815 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetDatafeedStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeeds = System.Text.Json.JsonEncodedText.Encode("datafeeds"); + + public override GetDatafeedStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDatafeeds.TryRead(ref reader, options, PropDatafeeds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDatafeedStatsResponse + { + Count = propCount.Value +, + Datafeeds = propDatafeeds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDatafeedStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDatafeedStatsResponseConverter))] public sealed partial class GetDatafeedStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("datafeeds")] public IReadOnlyCollection Datafeeds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs index caa45e6562a..0b7ceb7dc56 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetDatafeedsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeeds = System.Text.Json.JsonEncodedText.Encode("datafeeds"); + + public override GetDatafeedsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDatafeeds.TryRead(ref reader, options, PropDatafeeds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDatafeedsResponse + { + Count = propCount.Value +, + Datafeeds = propDatafeeds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDatafeedsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDatafeedsResponseConverter))] public sealed partial class GetDatafeedsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("datafeeds")] public IReadOnlyCollection Datafeeds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs index 428014f53fa..7a73fe87223 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetFiltersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropFilters = System.Text.Json.JsonEncodedText.Encode("filters"); + + public override GetFiltersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propFilters = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propFilters.TryRead(ref reader, options, PropFilters)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetFiltersResponse + { + Count = propCount.Value +, + Filters = propFilters.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetFiltersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropFilters, value.Filters); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetFiltersResponseConverter))] public sealed partial class GetFiltersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("filters")] public IReadOnlyCollection Filters { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs index 3d09d58a4df..d45f15ed7ae 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetInfluencersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropInfluencers = System.Text.Json.JsonEncodedText.Encode("influencers"); + + public override GetInfluencersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propInfluencers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propInfluencers.TryRead(ref reader, options, PropInfluencers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetInfluencersResponse + { + Count = propCount.Value +, + Influencers = propInfluencers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetInfluencersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropInfluencers, value.Influencers); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetInfluencersResponseConverter))] public sealed partial class GetInfluencersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class GetInfluencersResponse : ElasticsearchResponse /// Array of influencer objects /// /// - [JsonInclude, JsonPropertyName("influencers")] public IReadOnlyCollection Influencers { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs index 52145377e72..f322ac3ccb0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetJobStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropJobs = System.Text.Json.JsonEncodedText.Encode("jobs"); + + public override GetJobStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propJobs.TryRead(ref reader, options, PropJobs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetJobStatsResponse + { + Count = propCount.Value +, + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropJobs, value.Jobs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobStatsResponseConverter))] public sealed partial class GetJobStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobsResponse.g.cs index c49c0f0fc55..c864fa4d783 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetJobsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetJobsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropJobs = System.Text.Json.JsonEncodedText.Encode("jobs"); + + public override GetJobsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propJobs.TryRead(ref reader, options, PropJobs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetJobsResponse + { + Count = propCount.Value +, + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropJobs, value.Jobs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobsResponseConverter))] public sealed partial class GetJobsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs index 5160f398936..039dbb453bf 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetMemoryStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStatistics = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override GetMemoryStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStatistics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStatistics.TryRead(ref reader, options, PropNodeStatistics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetMemoryStatsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStatistics = propNodeStatistics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetMemoryStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStatistics, value.NodeStatistics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetMemoryStatsResponseConverter))] public sealed partial class GetMemoryStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStatistics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs index da5c014af7e..2ae4d68a213 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetModelSnapshotUpgradeStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotUpgrades = System.Text.Json.JsonEncodedText.Encode("model_snapshot_upgrades"); + + public override GetModelSnapshotUpgradeStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propModelSnapshotUpgrades = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propModelSnapshotUpgrades.TryRead(ref reader, options, PropModelSnapshotUpgrades)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetModelSnapshotUpgradeStatsResponse + { + Count = propCount.Value +, + ModelSnapshotUpgrades = propModelSnapshotUpgrades.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetModelSnapshotUpgradeStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropModelSnapshotUpgrades, value.ModelSnapshotUpgrades); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetModelSnapshotUpgradeStatsResponseConverter))] public sealed partial class GetModelSnapshotUpgradeStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_upgrades")] public IReadOnlyCollection ModelSnapshotUpgrades { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs index 080fdc6766e..6efd1736d51 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetModelSnapshotsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshots = System.Text.Json.JsonEncodedText.Encode("model_snapshots"); + + public override GetModelSnapshotsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propModelSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propModelSnapshots.TryRead(ref reader, options, PropModelSnapshots)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetModelSnapshotsResponse + { + Count = propCount.Value +, + ModelSnapshots = propModelSnapshots.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetModelSnapshotsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropModelSnapshots, value.ModelSnapshots); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetModelSnapshotsResponseConverter))] public sealed partial class GetModelSnapshotsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("model_snapshots")] public IReadOnlyCollection ModelSnapshots { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs index f5d132ee50e..90e42d44ab2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetOverallBucketsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropOverallBuckets = System.Text.Json.JsonEncodedText.Encode("overall_buckets"); + + public override GetOverallBucketsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propOverallBuckets = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propOverallBuckets.TryRead(ref reader, options, PropOverallBuckets)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetOverallBucketsResponse + { + Count = propCount.Value +, + OverallBuckets = propOverallBuckets.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetOverallBucketsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropOverallBuckets, value.OverallBuckets); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetOverallBucketsResponseConverter))] public sealed partial class GetOverallBucketsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class GetOverallBucketsResponse : ElasticsearchResponse /// Array of overall bucket objects /// /// - [JsonInclude, JsonPropertyName("overall_buckets")] public IReadOnlyCollection OverallBuckets { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs index a7e647c1031..0447542c7ea 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetRecordsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropRecords = System.Text.Json.JsonEncodedText.Encode("records"); + + public override GetRecordsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propRecords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propRecords.TryRead(ref reader, options, PropRecords)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRecordsResponse + { + Count = propCount.Value +, + Records = propRecords.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRecordsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropRecords, value.Records); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRecordsResponseConverter))] public sealed partial class GetRecordsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("records")] public IReadOnlyCollection Records { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs index cd391598dfc..c6a85b72331 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetTrainedModelsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTrainedModelConfigs = System.Text.Json.JsonEncodedText.Encode("trained_model_configs"); + + public override GetTrainedModelsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propTrainedModelConfigs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTrainedModelConfigs.TryRead(ref reader, options, PropTrainedModelConfigs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrainedModelsResponse + { + Count = propCount.Value +, + TrainedModelConfigs = propTrainedModelConfigs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrainedModelsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTrainedModelConfigs, value.TrainedModelConfigs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsResponseConverter))] public sealed partial class GetTrainedModelsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class GetTrainedModelsResponse : ElasticsearchResponse /// An array of trained model resources, which are sorted by the model_id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("trained_model_configs")] public IReadOnlyCollection TrainedModelConfigs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs index ae4dc05f018..52c0c1748a1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class GetTrainedModelsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTrainedModelStats = System.Text.Json.JsonEncodedText.Encode("trained_model_stats"); + + public override GetTrainedModelsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propTrainedModelStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTrainedModelStats.TryRead(ref reader, options, PropTrainedModelStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrainedModelsStatsResponse + { + Count = propCount.Value +, + TrainedModelStats = propTrainedModelStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrainedModelsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTrainedModelStats, value.TrainedModelStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsStatsResponseConverter))] public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchRespons /// The total number of trained model statistics that matched the requested ID patterns. Could be higher than the number of items in the trained_model_stats array as the size of the array is restricted by the supplied size parameter. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchRespons /// An array of trained model statistics, which are sorted by the model_id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("trained_model_stats")] public IReadOnlyCollection TrainedModelStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs index 098482e4cab..3a29d6ea225 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class InferTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInferenceResults = System.Text.Json.JsonEncodedText.Encode("inference_results"); + + public override InferTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propInferenceResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceResults.TryRead(ref reader, options, PropInferenceResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferTrainedModelResponse + { + InferenceResults = propInferenceResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInferenceResults, value.InferenceResults); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferTrainedModelResponseConverter))] public sealed partial class InferTrainedModelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("inference_results")] public IReadOnlyCollection InferenceResults { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/MlInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/MlInfoResponse.g.cs index 259dbfea229..6e897619369 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/MlInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/MlInfoResponse.g.cs @@ -18,22 +18,85 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class MlInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefaults = System.Text.Json.JsonEncodedText.Encode("defaults"); + private static readonly System.Text.Json.JsonEncodedText PropLimits = System.Text.Json.JsonEncodedText.Encode("limits"); + private static readonly System.Text.Json.JsonEncodedText PropNativeCode = System.Text.Json.JsonEncodedText.Encode("native_code"); + private static readonly System.Text.Json.JsonEncodedText PropUpgradeMode = System.Text.Json.JsonEncodedText.Encode("upgrade_mode"); + + public override MlInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDefaults = default; + LocalJsonProperty propLimits = default; + LocalJsonProperty propNativeCode = default; + LocalJsonProperty propUpgradeMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryRead(ref reader, options, PropDefaults)) + { + continue; + } + + if (propLimits.TryRead(ref reader, options, PropLimits)) + { + continue; + } + + if (propNativeCode.TryRead(ref reader, options, PropNativeCode)) + { + continue; + } + + if (propUpgradeMode.TryRead(ref reader, options, PropUpgradeMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MlInfoResponse + { + Defaults = propDefaults.Value +, + Limits = propLimits.Value +, + NativeCode = propNativeCode.Value +, + UpgradeMode = propUpgradeMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MlInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefaults, value.Defaults); + writer.WriteProperty(options, PropLimits, value.Limits); + writer.WriteProperty(options, PropNativeCode, value.NativeCode); + writer.WriteProperty(options, PropUpgradeMode, value.UpgradeMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MlInfoResponseConverter))] public sealed partial class MlInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("defaults")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Defaults Defaults { get; init; } - [JsonInclude, JsonPropertyName("limits")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Limits Limits { get; init; } - [JsonInclude, JsonPropertyName("native_code")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NativeCode NativeCode { get; init; } - [JsonInclude, JsonPropertyName("upgrade_mode")] public bool UpgradeMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/OpenJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/OpenJobResponse.g.cs index cd43a5e3eda..a4f4a39d157 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/OpenJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/OpenJobResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class OpenJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropOpened = System.Text.Json.JsonEncodedText.Encode("opened"); + + public override OpenJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propNode = default; + LocalJsonProperty propOpened = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + if (propOpened.TryRead(ref reader, options, PropOpened)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenJobResponse + { + Node = propNode.Value +, + Opened = propOpened.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteProperty(options, PropOpened, value.Opened); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenJobResponseConverter))] public sealed partial class OpenJobResponse : ElasticsearchResponse { /// @@ -34,8 +81,6 @@ public sealed partial class OpenJobResponse : ElasticsearchResponse /// If the job is allowed to open lazily and has not yet been assigned to a node, this value is an empty string. /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } - [JsonInclude, JsonPropertyName("opened")] public bool Opened { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs index f667f11c4bb..ea49ecdcf57 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PostCalendarEventsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + + public override PostCalendarEventsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostCalendarEventsResponse + { + Events = propEvents.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostCalendarEventsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostCalendarEventsResponseConverter))] public sealed partial class PostCalendarEventsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection Events { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs index aaa361ed3cb..9817ab57898 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PreviewDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatureValues = System.Text.Json.JsonEncodedText.Encode("feature_values"); + + public override PreviewDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>> propFeatureValues = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureValues.TryRead(ref reader, options, PropFeatureValues)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PreviewDataFrameAnalyticsResponse + { + FeatureValues = propFeatureValues.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PreviewDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureValues, value.FeatureValues); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PreviewDataFrameAnalyticsResponseConverter))] public sealed partial class PreviewDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PreviewDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that contain feature name and value pairs. The features have been processed and indicate what will be sent to the model for training. /// /// - [JsonInclude, JsonPropertyName("feature_values")] public IReadOnlyCollection> FeatureValues { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs index b1d318b6602..84013fc93de 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutCalendarJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override PutCalendarJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCalendarId = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutCalendarJobResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutCalendarJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarJobResponseConverter))] public sealed partial class PutCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +104,5 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs index 6196799ffd7..1988a684b42 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutCalendarResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override PutCalendarResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCalendarId = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutCalendarResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutCalendarResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarResponseConverter))] public sealed partial class PutCalendarResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +104,5 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs index 60f90198ccf..c576b65bbe0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs @@ -18,40 +18,184 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyStart = System.Text.Json.JsonEncodedText.Encode("allow_lazy_start"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzedFields = System.Text.Json.JsonEncodedText.Encode("analyzed_fields"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNumThreads = System.Text.Json.JsonEncodedText.Encode("max_num_threads"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryLimit = System.Text.Json.JsonEncodedText.Encode("model_memory_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowLazyStart = default; + LocalJsonProperty propAnalysis = default; + LocalJsonProperty propAnalyzedFields = default; + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propDest = default; + LocalJsonProperty propId = default; + LocalJsonProperty propMaxNumThreads = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propModelMemoryLimit = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryRead(ref reader, options, PropAllowLazyStart)) + { + continue; + } + + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) + { + continue; + } + + if (propAnalyzedFields.TryRead(ref reader, options, PropAnalyzedFields)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propMaxNumThreads.TryRead(ref reader, options, PropMaxNumThreads)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propModelMemoryLimit.TryRead(ref reader, options, PropModelMemoryLimit)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDataFrameAnalyticsResponse + { + AllowLazyStart = propAllowLazyStart.Value +, + Analysis = propAnalysis.Value +, + AnalyzedFields = propAnalyzedFields.Value +, + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Id = propId.Value +, + MaxNumThreads = propMaxNumThreads.Value +, + Meta = propMeta.Value +, + ModelMemoryLimit = propModelMemoryLimit.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyStart, value.AllowLazyStart); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDataFrameAnalyticsResponseConverter))] public sealed partial class PutDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_start")] public bool AllowLazyStart { get; init; } - [JsonInclude, JsonPropertyName("analysis")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsDestination Dest { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("max_num_threads")] public int MaxNumThreads { get; init; } - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } - [JsonInclude, JsonPropertyName("model_memory_limit")] public string ModelMemoryLimit { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsSource Source { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs index a37c4b8b3ae..0271ffc3085 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -56,194 +57,167 @@ public sealed partial class PutDatafeedRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } -internal sealed partial class PutDatafeedRequestConverter : JsonConverter +internal sealed partial class PutDatafeedRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override PutDatafeedRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropHeaders = System.Text.Json.JsonEncodedText.Encode("headers"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override PutDatafeedRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new PutDatafeedRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty>>?> propHeaders = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "headers") - { - variant.Headers = JsonSerializer.Deserialize>>?>(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, PutDatafeedRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propHeaders.TryRead(ref reader, options, PropHeaders)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Headers is not null) - { - writer.WritePropertyName("headers"); - JsonSerializer.Serialize(writer, value.Headers, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDatafeedRequest { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value + , + ChunkingConfig = propChunkingConfig.Value + , + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value + , + Frequency = propFrequency.Value + , + Headers = propHeaders.Value + , + Indices = propIndices.Value + , + IndicesOptions = propIndicesOptions.Value + , + JobId = propJobId.Value + , + MaxEmptySearches = propMaxEmptySearches.Value + , + Query = propQuery.Value + , + QueryDelay = propQueryDelay.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDatafeedRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropHeaders, value.Headers); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } @@ -289,7 +263,6 @@ public PutDatafeedRequest() /// string or when no indices are specified. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -298,7 +271,6 @@ public PutDatafeedRequest() /// whether wildcard expressions match hidden data streams. Supports comma-separated values. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -306,7 +278,6 @@ public PutDatafeedRequest() /// If true, unavailable indices (missing or closed) are ignored. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -315,7 +286,6 @@ public PutDatafeedRequest() /// Support for aggregations is limited and should be used only with low cardinality data. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -326,7 +296,6 @@ public PutDatafeedRequest() /// it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -338,7 +307,6 @@ public PutDatafeedRequest() /// This check runs only on real-time datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -350,9 +318,7 @@ public PutDatafeedRequest() /// aggregations, this value must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Frequency { get; set; } - [JsonInclude, JsonPropertyName("headers")] public IDictionary>>? Headers { get; set; } /// @@ -361,7 +327,6 @@ public PutDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } /// @@ -369,7 +334,6 @@ public PutDatafeedRequest() /// Specifies index expansion options that are used during search /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.Serverless.IndicesOptions? IndicesOptions { get; set; } /// @@ -377,7 +341,6 @@ public PutDatafeedRequest() /// Identifier for the anomaly detection job. /// /// - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Serverless.Id? JobId { get; set; } /// @@ -388,7 +351,6 @@ public PutDatafeedRequest() /// end time that sees no data remains started until it is explicitly stopped. By default, it is not set. /// /// - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; set; } /// @@ -398,7 +360,6 @@ public PutDatafeedRequest() /// object is passed verbatim to Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } /// @@ -409,7 +370,6 @@ public PutDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration? QueryDelay { get; set; } /// @@ -417,7 +377,6 @@ public PutDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -426,7 +385,6 @@ public PutDatafeedRequest() /// The detector configuration objects in a job can contain functions that use these script fields. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -435,7 +393,6 @@ public PutDatafeedRequest() /// The maximum value is the value of index.max_result_window, which is 10,000 by default. /// /// - [JsonInclude, JsonPropertyName("scroll_size")] public int? ScrollSize { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs index ddabcb1e4ee..2fdf48bb548 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs @@ -18,44 +18,206 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override PutDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDatafeedId = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty> propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDatafeedResponse + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDatafeedResponseConverter))] public sealed partial class PutDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.Serverless.IndicesOptions? IndicesOptions { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration QueryDelay { get; init; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IReadOnlyDictionary? RuntimeMappings { get; init; } - [JsonInclude, JsonPropertyName("script_fields")] public IReadOnlyDictionary? ScriptFields { get; init; } - [JsonInclude, JsonPropertyName("scroll_size")] public int ScrollSize { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutFilterResponse.g.cs index 20f12bc44f0..a96ca88a343 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutFilterResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFilterId = System.Text.Json.JsonEncodedText.Encode("filter_id"); + private static readonly System.Text.Json.JsonEncodedText PropItems = System.Text.Json.JsonEncodedText.Encode("items"); + + public override PutFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDescription = default; + LocalJsonProperty propFilterId = default; + LocalJsonProperty> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFilterId.TryRead(ref reader, options, PropFilterId)) + { + continue; + } + + if (propItems.TryRead(ref reader, options, PropItems)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutFilterResponse + { + Description = propDescription.Value +, + FilterId = propFilterId.Value +, + Items = propItems.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFilterId, value.FilterId); + writer.WriteProperty(options, PropItems, value.Items); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutFilterResponseConverter))] public sealed partial class PutFilterResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("filter_id")] public string FilterId { get; init; } - [JsonInclude, JsonPropertyName("items")] public IReadOnlyCollection Items { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutJobResponse.g.cs index 4046c33265f..02e9513411b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutJobResponse.g.cs @@ -18,54 +18,261 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyOpen = System.Text.Json.JsonEncodedText.Encode("allow_lazy_open"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisConfig = System.Text.Json.JsonEncodedText.Encode("analysis_config"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisLimits = System.Text.Json.JsonEncodedText.Encode("analysis_limits"); + private static readonly System.Text.Json.JsonEncodedText PropBackgroundPersistInterval = System.Text.Json.JsonEncodedText.Encode("background_persist_interval"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropCustomSettings = System.Text.Json.JsonEncodedText.Encode("custom_settings"); + private static readonly System.Text.Json.JsonEncodedText PropDailyModelSnapshotRetentionAfterDays = System.Text.Json.JsonEncodedText.Encode("daily_model_snapshot_retention_after_days"); + private static readonly System.Text.Json.JsonEncodedText PropDataDescription = System.Text.Json.JsonEncodedText.Encode("data_description"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedConfig = System.Text.Json.JsonEncodedText.Encode("datafeed_config"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropGroups = System.Text.Json.JsonEncodedText.Encode("groups"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropJobType = System.Text.Json.JsonEncodedText.Encode("job_type"); + private static readonly System.Text.Json.JsonEncodedText PropJobVersion = System.Text.Json.JsonEncodedText.Encode("job_version"); + private static readonly System.Text.Json.JsonEncodedText PropModelPlotConfig = System.Text.Json.JsonEncodedText.Encode("model_plot_config"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotId = System.Text.Json.JsonEncodedText.Encode("model_snapshot_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotRetentionDays = System.Text.Json.JsonEncodedText.Encode("model_snapshot_retention_days"); + private static readonly System.Text.Json.JsonEncodedText PropRenormalizationWindowDays = System.Text.Json.JsonEncodedText.Encode("renormalization_window_days"); + private static readonly System.Text.Json.JsonEncodedText PropResultsIndexName = System.Text.Json.JsonEncodedText.Encode("results_index_name"); + private static readonly System.Text.Json.JsonEncodedText PropResultsRetentionDays = System.Text.Json.JsonEncodedText.Encode("results_retention_days"); + + public override PutJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowLazyOpen = default; + LocalJsonProperty propAnalysisConfig = default; + LocalJsonProperty propAnalysisLimits = default; + LocalJsonProperty propBackgroundPersistInterval = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty propCustomSettings = default; + LocalJsonProperty propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonProperty propDataDescription = default; + LocalJsonProperty propDatafeedConfig = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty?> propGroups = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propJobType = default; + LocalJsonProperty propJobVersion = default; + LocalJsonProperty propModelPlotConfig = default; + LocalJsonProperty propModelSnapshotId = default; + LocalJsonProperty propModelSnapshotRetentionDays = default; + LocalJsonProperty propRenormalizationWindowDays = default; + LocalJsonProperty propResultsIndexName = default; + LocalJsonProperty propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryRead(ref reader, options, PropAllowLazyOpen)) + { + continue; + } + + if (propAnalysisConfig.TryRead(ref reader, options, PropAnalysisConfig)) + { + continue; + } + + if (propAnalysisLimits.TryRead(ref reader, options, PropAnalysisLimits)) + { + continue; + } + + if (propBackgroundPersistInterval.TryRead(ref reader, options, PropBackgroundPersistInterval)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propCustomSettings.TryRead(ref reader, options, PropCustomSettings)) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryRead(ref reader, options, PropDailyModelSnapshotRetentionAfterDays)) + { + continue; + } + + if (propDataDescription.TryRead(ref reader, options, PropDataDescription)) + { + continue; + } + + if (propDatafeedConfig.TryRead(ref reader, options, PropDatafeedConfig)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propGroups.TryRead(ref reader, options, PropGroups)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propJobType.TryRead(ref reader, options, PropJobType)) + { + continue; + } + + if (propJobVersion.TryRead(ref reader, options, PropJobVersion)) + { + continue; + } + + if (propModelPlotConfig.TryRead(ref reader, options, PropModelPlotConfig)) + { + continue; + } + + if (propModelSnapshotId.TryRead(ref reader, options, PropModelSnapshotId)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryRead(ref reader, options, PropModelSnapshotRetentionDays)) + { + continue; + } + + if (propRenormalizationWindowDays.TryRead(ref reader, options, PropRenormalizationWindowDays)) + { + continue; + } + + if (propResultsIndexName.TryRead(ref reader, options, PropResultsIndexName)) + { + continue; + } + + if (propResultsRetentionDays.TryRead(ref reader, options, PropResultsRetentionDays)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutJobResponse + { + AllowLazyOpen = propAllowLazyOpen.Value +, + AnalysisConfig = propAnalysisConfig.Value +, + AnalysisLimits = propAnalysisLimits.Value +, + BackgroundPersistInterval = propBackgroundPersistInterval.Value +, + CreateTime = propCreateTime.Value +, + CustomSettings = propCustomSettings.Value +, + DailyModelSnapshotRetentionAfterDays = propDailyModelSnapshotRetentionAfterDays.Value +, + DataDescription = propDataDescription.Value +, + DatafeedConfig = propDatafeedConfig.Value +, + Description = propDescription.Value +, + Groups = propGroups.Value +, + JobId = propJobId.Value +, + JobType = propJobType.Value +, + JobVersion = propJobVersion.Value +, + ModelPlotConfig = propModelPlotConfig.Value +, + ModelSnapshotId = propModelSnapshotId.Value +, + ModelSnapshotRetentionDays = propModelSnapshotRetentionDays.Value +, + RenormalizationWindowDays = propRenormalizationWindowDays.Value +, + ResultsIndexName = propResultsIndexName.Value +, + ResultsRetentionDays = propResultsRetentionDays.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyOpen, value.AllowLazyOpen); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays); + writer.WriteProperty(options, PropDataDescription, value.DataDescription); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropGroups, value.Groups); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropJobType, value.JobType); + writer.WriteProperty(options, PropJobVersion, value.JobVersion); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutJobResponseConverter))] public sealed partial class PutJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_open")] public bool AllowLazyOpen { get; init; } - [JsonInclude, JsonPropertyName("analysis_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.Serverless.Duration? BackgroundPersistInterval { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public DateTimeOffset CreateTime { get; init; } - [JsonInclude, JsonPropertyName("custom_settings")] public object? CustomSettings { get; init; } - [JsonInclude, JsonPropertyName("daily_model_snapshot_retention_after_days")] public long DailyModelSnapshotRetentionAfterDays { get; init; } - [JsonInclude, JsonPropertyName("data_description")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Datafeed? DatafeedConfig { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("groups")] public IReadOnlyCollection? Groups { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("job_type")] public string JobType { get; init; } - [JsonInclude, JsonPropertyName("job_version")] public string JobVersion { get; init; } - [JsonInclude, JsonPropertyName("model_plot_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? ModelPlotConfig { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_id")] public string? ModelSnapshotId { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_retention_days")] public long ModelSnapshotRetentionDays { get; init; } - [JsonInclude, JsonPropertyName("renormalization_window_days")] public long? RenormalizationWindowDays { get; init; } - [JsonInclude, JsonPropertyName("results_index_name")] public string ResultsIndexName { get; init; } - [JsonInclude, JsonPropertyName("results_retention_days")] public long? ResultsRetentionDays { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs index 8fa9c7fa77b..211575dc08d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutTrainedModelAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelAliasResponseConverter))] public sealed partial class PutTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutTrainedModelAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs index dd3c200a6b1..08bc3f259f6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutTrainedModelDefinitionPartResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelDefinitionPartResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelDefinitionPartResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelDefinitionPartResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelDefinitionPartResponseConverter))] public sealed partial class PutTrainedModelDefinitionPartResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutTrainedModelDefinitionPartResponse : Elasticsearc /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs index 93ed85a9966..530f6708ec4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs @@ -18,17 +18,243 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompressedDefinition = System.Text.Json.JsonEncodedText.Encode("compressed_definition"); + private static readonly System.Text.Json.JsonEncodedText PropCreatedBy = System.Text.Json.JsonEncodedText.Encode("created_by"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultFieldMap = System.Text.Json.JsonEncodedText.Encode("default_field_map"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropEstimatedHeapMemoryUsageBytes = System.Text.Json.JsonEncodedText.Encode("estimated_heap_memory_usage_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropEstimatedOperations = System.Text.Json.JsonEncodedText.Encode("estimated_operations"); + private static readonly System.Text.Json.JsonEncodedText PropFullyDefined = System.Text.Json.JsonEncodedText.Encode("fully_defined"); + private static readonly System.Text.Json.JsonEncodedText PropInferenceConfig = System.Text.Json.JsonEncodedText.Encode("inference_config"); + private static readonly System.Text.Json.JsonEncodedText PropInput = System.Text.Json.JsonEncodedText.Encode("input"); + private static readonly System.Text.Json.JsonEncodedText PropLicenseLevel = System.Text.Json.JsonEncodedText.Encode("license_level"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropModelId = System.Text.Json.JsonEncodedText.Encode("model_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelPackage = System.Text.Json.JsonEncodedText.Encode("model_package"); + private static readonly System.Text.Json.JsonEncodedText PropModelSizeBytes = System.Text.Json.JsonEncodedText.Encode("model_size_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropModelType = System.Text.Json.JsonEncodedText.Encode("model_type"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixStrings = System.Text.Json.JsonEncodedText.Encode("prefix_strings"); + private static readonly System.Text.Json.JsonEncodedText PropTags = System.Text.Json.JsonEncodedText.Encode("tags"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompressedDefinition = default; + LocalJsonProperty propCreatedBy = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty?> propDefaultFieldMap = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propEstimatedHeapMemoryUsageBytes = default; + LocalJsonProperty propEstimatedOperations = default; + LocalJsonProperty propFullyDefined = default; + LocalJsonProperty propInferenceConfig = default; + LocalJsonProperty propInput = default; + LocalJsonProperty propLicenseLevel = default; + LocalJsonProperty propLocation = default; + LocalJsonProperty propMetadata = default; + LocalJsonProperty propModelId = default; + LocalJsonProperty propModelPackage = default; + LocalJsonProperty propModelSizeBytes = default; + LocalJsonProperty propModelType = default; + LocalJsonProperty propPrefixStrings = default; + LocalJsonProperty> propTags = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompressedDefinition.TryRead(ref reader, options, PropCompressedDefinition)) + { + continue; + } + + if (propCreatedBy.TryRead(ref reader, options, PropCreatedBy)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDefaultFieldMap.TryRead(ref reader, options, PropDefaultFieldMap)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propEstimatedHeapMemoryUsageBytes.TryRead(ref reader, options, PropEstimatedHeapMemoryUsageBytes)) + { + continue; + } + + if (propEstimatedOperations.TryRead(ref reader, options, PropEstimatedOperations)) + { + continue; + } + + if (propFullyDefined.TryRead(ref reader, options, PropFullyDefined)) + { + continue; + } + + if (propInferenceConfig.TryRead(ref reader, options, PropInferenceConfig)) + { + continue; + } + + if (propInput.TryRead(ref reader, options, PropInput)) + { + continue; + } + + if (propLicenseLevel.TryRead(ref reader, options, PropLicenseLevel)) + { + continue; + } + + if (propLocation.TryRead(ref reader, options, PropLocation)) + { + continue; + } + + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + if (propModelId.TryRead(ref reader, options, PropModelId)) + { + continue; + } + + if (propModelPackage.TryRead(ref reader, options, PropModelPackage)) + { + continue; + } + + if (propModelSizeBytes.TryRead(ref reader, options, PropModelSizeBytes)) + { + continue; + } + + if (propModelType.TryRead(ref reader, options, PropModelType)) + { + continue; + } + + if (propPrefixStrings.TryRead(ref reader, options, PropPrefixStrings)) + { + continue; + } + + if (propTags.TryRead(ref reader, options, PropTags)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelResponse + { + CompressedDefinition = propCompressedDefinition.Value +, + CreatedBy = propCreatedBy.Value +, + CreateTime = propCreateTime.Value +, + DefaultFieldMap = propDefaultFieldMap.Value +, + Description = propDescription.Value +, + EstimatedHeapMemoryUsageBytes = propEstimatedHeapMemoryUsageBytes.Value +, + EstimatedOperations = propEstimatedOperations.Value +, + FullyDefined = propFullyDefined.Value +, + InferenceConfig = propInferenceConfig.Value +, + Input = propInput.Value +, + LicenseLevel = propLicenseLevel.Value +, + Location = propLocation.Value +, + Metadata = propMetadata.Value +, + ModelId = propModelId.Value +, + ModelPackage = propModelPackage.Value +, + ModelSizeBytes = propModelSizeBytes.Value +, + ModelType = propModelType.Value +, + PrefixStrings = propPrefixStrings.Value +, + Tags = propTags.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompressedDefinition, value.CompressedDefinition); + writer.WriteProperty(options, PropCreatedBy, value.CreatedBy); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDefaultFieldMap, value.DefaultFieldMap); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropEstimatedHeapMemoryUsageBytes, value.EstimatedHeapMemoryUsageBytes); + writer.WriteProperty(options, PropEstimatedOperations, value.EstimatedOperations); + writer.WriteProperty(options, PropFullyDefined, value.FullyDefined); + writer.WriteProperty(options, PropInferenceConfig, value.InferenceConfig); + writer.WriteProperty(options, PropInput, value.Input); + writer.WriteProperty(options, PropLicenseLevel, value.LicenseLevel); + writer.WriteProperty(options, PropLocation, value.Location); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteProperty(options, PropModelId, value.ModelId); + writer.WriteProperty(options, PropModelPackage, value.ModelPackage); + writer.WriteProperty(options, PropModelSizeBytes, value.ModelSizeBytes); + writer.WriteProperty(options, PropModelType, value.ModelType); + writer.WriteProperty(options, PropPrefixStrings, value.PrefixStrings); + writer.WriteProperty(options, PropTags, value.Tags); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelResponseConverter))] public sealed partial class PutTrainedModelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("compressed_definition")] public string? CompressedDefinition { get; init; } /// @@ -36,7 +262,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Information on the creator of the trained model. /// /// - [JsonInclude, JsonPropertyName("created_by")] public string? CreatedBy { get; init; } /// @@ -44,7 +269,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The time when the trained model was created. /// /// - [JsonInclude, JsonPropertyName("create_time")] public DateTimeOffset? CreateTime { get; init; } /// @@ -52,7 +276,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Any field map described in the inference configuration takes precedence. /// /// - [JsonInclude, JsonPropertyName("default_field_map")] public IReadOnlyDictionary? DefaultFieldMap { get; init; } /// @@ -60,7 +283,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The free-text description of the trained model. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -68,7 +290,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The estimated heap usage in bytes to keep the trained model in memory. /// /// - [JsonInclude, JsonPropertyName("estimated_heap_memory_usage_bytes")] public int? EstimatedHeapMemoryUsageBytes { get; init; } /// @@ -76,7 +297,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The estimated number of operations to use the trained model. /// /// - [JsonInclude, JsonPropertyName("estimated_operations")] public int? EstimatedOperations { get; init; } /// @@ -84,7 +304,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// True if the full model definition is present. /// /// - [JsonInclude, JsonPropertyName("fully_defined")] public bool? FullyDefined { get; init; } /// @@ -92,7 +311,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The default configuration for inference. This can be either a regression, classification, or one of the many NLP focused configurations. It must match the underlying definition.trained_model's target_type. For pre-packaged models such as ELSER the config is not required. /// /// - [JsonInclude, JsonPropertyName("inference_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.InferenceConfigCreate? InferenceConfig { get; init; } /// @@ -100,7 +318,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The input field names for the model definition. /// /// - [JsonInclude, JsonPropertyName("input")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelConfigInput Input { get; init; } /// @@ -108,9 +325,7 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The license level of the trained model. /// /// - [JsonInclude, JsonPropertyName("license_level")] public string? LicenseLevel { get; init; } - [JsonInclude, JsonPropertyName("location")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelLocation? Location { get; init; } /// @@ -118,7 +333,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// An object containing metadata about the trained model. For example, models created by data frame analytics contain analysis_config and input objects. /// /// - [JsonInclude, JsonPropertyName("metadata")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelConfigMetadata? Metadata { get; init; } /// @@ -126,11 +340,8 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Identifier for the trained model. /// /// - [JsonInclude, JsonPropertyName("model_id")] public string ModelId { get; init; } - [JsonInclude, JsonPropertyName("model_package")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPackageConfig? ModelPackage { get; init; } - [JsonInclude, JsonPropertyName("model_size_bytes")] public Elastic.Clients.Elasticsearch.Serverless.ByteSize? ModelSizeBytes { get; init; } /// @@ -138,9 +349,7 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The model type /// /// - [JsonInclude, JsonPropertyName("model_type")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelType? ModelType { get; init; } - [JsonInclude, JsonPropertyName("prefix_strings")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelPrefixStrings? PrefixStrings { get; init; } /// @@ -148,7 +357,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// A comma delimited string of tags. A trained model can have many tags, or none. /// /// - [JsonInclude, JsonPropertyName("tags")] public IReadOnlyCollection Tags { get; init; } /// @@ -156,6 +364,5 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The Elasticsearch version number in which the trained model was created. /// /// - [JsonInclude, JsonPropertyName("version")] public string? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs index aeb196b185e..8b8821fa667 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class PutTrainedModelVocabularyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelVocabularyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelVocabularyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelVocabularyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelVocabularyResponseConverter))] public sealed partial class PutTrainedModelVocabularyResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutTrainedModelVocabularyResponse : ElasticsearchRes /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ResetJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ResetJobResponse.g.cs index b0d56d75278..fe1147eb6ed 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ResetJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ResetJobResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ResetJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResetJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetJobResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetJobResponseConverter))] public sealed partial class ResetJobResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ResetJobResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs index 019c156ac8b..5b0627b7cf8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class RevertModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropModel = System.Text.Json.JsonEncodedText.Encode("model"); + + public override RevertModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModel.TryRead(ref reader, options, PropModel)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RevertModelSnapshotResponse + { + Model = propModel.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RevertModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropModel, value.Model); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RevertModelSnapshotResponseConverter))] public sealed partial class RevertModelSnapshotResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("model")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs index 68adcc98b6f..1917737ebfa 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class SetUpgradeModeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override SetUpgradeModeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SetUpgradeModeResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SetUpgradeModeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SetUpgradeModeResponseConverter))] public sealed partial class SetUpgradeModeResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class SetUpgradeModeResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs index 87442b0d491..4f379e53d38 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StartDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + + public override StartDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartDataFrameAnalyticsResponse + { + Acknowledged = propAcknowledged.Value +, + Node = propNode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDataFrameAnalyticsResponseConverter))] public sealed partial class StartDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } /// @@ -40,6 +86,5 @@ public sealed partial class StartDataFrameAnalyticsResponse : ElasticsearchRespo /// node ID will be "serverless". /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs index 032255be81e..5c5a5da2e56 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StartDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override StartDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propNode = default; + LocalJsonProperty propStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryRead(ref reader, options, PropNode, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propStarted.TryRead(ref reader, options, PropStarted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartDatafeedResponse + { + Node = propNode.Value +, + Started = propStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNode, value.Node, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropStarted, value.Started); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDatafeedResponseConverter))] public sealed partial class StartDatafeedResponse : ElasticsearchResponse { /// @@ -34,8 +81,6 @@ public sealed partial class StartDatafeedResponse : ElasticsearchResponse /// If the job is allowed to open lazily and has not yet been assigned to a node, this value is an empty string. /// /// - [JsonInclude, JsonPropertyName("node")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Node { get; init; } /// @@ -43,6 +88,5 @@ public sealed partial class StartDatafeedResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("started")] public bool Started { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs index 0dd0ac3a36d..14e98a396a1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StartTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAssignment = System.Text.Json.JsonEncodedText.Encode("assignment"); + + public override StartTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAssignment = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAssignment.TryRead(ref reader, options, PropAssignment)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartTrainedModelDeploymentResponse + { + Assignment = propAssignment.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAssignment, value.Assignment); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTrainedModelDeploymentResponseConverter))] public sealed partial class StartTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("assignment")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TrainedModelAssignment Assignment { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs index 1617f80e0a0..3cf98300849 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StopDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopDataFrameAnalyticsResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopDataFrameAnalyticsResponseConverter))] public sealed partial class StopDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs index 0b7e5f25c34..f93d457cce8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StopDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopDatafeedResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopDatafeedResponseConverter))] public sealed partial class StopDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs index 76069cdce24..2084fe95f25 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class StopTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTrainedModelDeploymentResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTrainedModelDeploymentResponseConverter))] public sealed partial class StopTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs index 0f44712ded6..797f5167792 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs @@ -18,38 +18,173 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpdateDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyStart = System.Text.Json.JsonEncodedText.Encode("allow_lazy_start"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzedFields = System.Text.Json.JsonEncodedText.Encode("analyzed_fields"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNumThreads = System.Text.Json.JsonEncodedText.Encode("max_num_threads"); + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryLimit = System.Text.Json.JsonEncodedText.Encode("model_memory_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override UpdateDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowLazyStart = default; + LocalJsonProperty propAnalysis = default; + LocalJsonProperty propAnalyzedFields = default; + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propDest = default; + LocalJsonProperty propId = default; + LocalJsonProperty propMaxNumThreads = default; + LocalJsonProperty propModelMemoryLimit = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryRead(ref reader, options, PropAllowLazyStart)) + { + continue; + } + + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) + { + continue; + } + + if (propAnalyzedFields.TryRead(ref reader, options, PropAnalyzedFields)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propMaxNumThreads.TryRead(ref reader, options, PropMaxNumThreads)) + { + continue; + } + + if (propModelMemoryLimit.TryRead(ref reader, options, PropModelMemoryLimit)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDataFrameAnalyticsResponse + { + AllowLazyStart = propAllowLazyStart.Value +, + Analysis = propAnalysis.Value +, + AnalyzedFields = propAnalyzedFields.Value +, + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Id = propId.Value +, + MaxNumThreads = propMaxNumThreads.Value +, + ModelMemoryLimit = propModelMemoryLimit.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyStart, value.AllowLazyStart); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateDataFrameAnalyticsResponseConverter))] public sealed partial class UpdateDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_start")] public bool AllowLazyStart { get; init; } - [JsonInclude, JsonPropertyName("analysis")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsDestination Dest { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("max_num_threads")] public int MaxNumThreads { get; init; } - [JsonInclude, JsonPropertyName("model_memory_limit")] public string ModelMemoryLimit { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalyticsSource Source { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs index 4a7029991d4..3f474174fe8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -83,182 +84,156 @@ public sealed partial class UpdateDatafeedRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } -internal sealed partial class UpdateDatafeedRequestConverter : JsonConverter +internal sealed partial class UpdateDatafeedRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override UpdateDatafeedRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override UpdateDatafeedRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new UpdateDatafeedRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty?> propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations)) { - var property = reader.GetString(); - if (property == "aggregations") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, UpdateDatafeedRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDatafeedRequest { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value + , + ChunkingConfig = propChunkingConfig.Value + , + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value + , + Frequency = propFrequency.Value + , + Indices = propIndices.Value + , + IndicesOptions = propIndicesOptions.Value + , + JobId = propJobId.Value + , + MaxEmptySearches = propMaxEmptySearches.Value + , + Query = propQuery.Value + , + QueryDelay = propQueryDelay.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDatafeedRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } @@ -297,7 +272,6 @@ public UpdateDatafeedRequest() /// _all string or when no indices are specified. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -333,7 +307,6 @@ public UpdateDatafeedRequest() /// /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -341,7 +314,6 @@ public UpdateDatafeedRequest() /// If true, unavailable indices (missing or closed) are ignored. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -350,7 +322,6 @@ public UpdateDatafeedRequest() /// with low cardinality data. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -360,7 +331,6 @@ public UpdateDatafeedRequest() /// these time chunks are calculated; it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -372,7 +342,6 @@ public UpdateDatafeedRequest() /// datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -384,7 +353,6 @@ public UpdateDatafeedRequest() /// must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Frequency { get; set; } /// @@ -393,7 +361,6 @@ public UpdateDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public ICollection? Indices { get; set; } /// @@ -401,9 +368,7 @@ public UpdateDatafeedRequest() /// Specifies index expansion options that are used during search. /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.Serverless.IndicesOptions? IndicesOptions { get; set; } - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Serverless.Id? JobId { get; set; } /// @@ -414,7 +379,6 @@ public UpdateDatafeedRequest() /// end time that sees no data remains started until it is explicitly stopped. By default, it is not set. /// /// - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; set; } /// @@ -428,7 +392,6 @@ public UpdateDatafeedRequest() /// when you are satisfied with the results of the job. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } /// @@ -439,7 +402,6 @@ public UpdateDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration? QueryDelay { get; set; } /// @@ -447,7 +409,6 @@ public UpdateDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -456,7 +417,6 @@ public UpdateDatafeedRequest() /// The detector configuration objects in a job can contain functions that use these script fields. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -465,7 +425,6 @@ public UpdateDatafeedRequest() /// The maximum value is the value of index.max_result_window. /// /// - [JsonInclude, JsonPropertyName("scroll_size")] public int? ScrollSize { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs index dd2d54e3dd8..9c4e801ca56 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs @@ -18,44 +18,206 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpdateDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override UpdateDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDatafeedId = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty> propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDatafeedResponse + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateDatafeedResponseConverter))] public sealed partial class UpdateDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.Serverless.IndicesOptions? IndicesOptions { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Serverless.Duration QueryDelay { get; init; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IReadOnlyDictionary? RuntimeMappings { get; init; } - [JsonInclude, JsonPropertyName("script_fields")] public IReadOnlyDictionary? ScriptFields { get; init; } - [JsonInclude, JsonPropertyName("scroll_size")] public int ScrollSize { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs index bb37ade045d..4395dac504f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpdateFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFilterId = System.Text.Json.JsonEncodedText.Encode("filter_id"); + private static readonly System.Text.Json.JsonEncodedText PropItems = System.Text.Json.JsonEncodedText.Encode("items"); + + public override UpdateFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDescription = default; + LocalJsonProperty propFilterId = default; + LocalJsonProperty> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFilterId.TryRead(ref reader, options, PropFilterId)) + { + continue; + } + + if (propItems.TryRead(ref reader, options, PropItems)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateFilterResponse + { + Description = propDescription.Value +, + FilterId = propFilterId.Value +, + Items = propItems.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFilterId, value.FilterId); + writer.WriteProperty(options, PropItems, value.Items); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateFilterResponseConverter))] public sealed partial class UpdateFilterResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("filter_id")] public string FilterId { get; init; } - [JsonInclude, JsonPropertyName("items")] public IReadOnlyCollection Items { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs index 3ed5d32ed5e..60368e86000 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs @@ -18,56 +18,272 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpdateJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyOpen = System.Text.Json.JsonEncodedText.Encode("allow_lazy_open"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisConfig = System.Text.Json.JsonEncodedText.Encode("analysis_config"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisLimits = System.Text.Json.JsonEncodedText.Encode("analysis_limits"); + private static readonly System.Text.Json.JsonEncodedText PropBackgroundPersistInterval = System.Text.Json.JsonEncodedText.Encode("background_persist_interval"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropCustomSettings = System.Text.Json.JsonEncodedText.Encode("custom_settings"); + private static readonly System.Text.Json.JsonEncodedText PropDailyModelSnapshotRetentionAfterDays = System.Text.Json.JsonEncodedText.Encode("daily_model_snapshot_retention_after_days"); + private static readonly System.Text.Json.JsonEncodedText PropDataDescription = System.Text.Json.JsonEncodedText.Encode("data_description"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedConfig = System.Text.Json.JsonEncodedText.Encode("datafeed_config"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFinishedTime = System.Text.Json.JsonEncodedText.Encode("finished_time"); + private static readonly System.Text.Json.JsonEncodedText PropGroups = System.Text.Json.JsonEncodedText.Encode("groups"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropJobType = System.Text.Json.JsonEncodedText.Encode("job_type"); + private static readonly System.Text.Json.JsonEncodedText PropJobVersion = System.Text.Json.JsonEncodedText.Encode("job_version"); + private static readonly System.Text.Json.JsonEncodedText PropModelPlotConfig = System.Text.Json.JsonEncodedText.Encode("model_plot_config"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotId = System.Text.Json.JsonEncodedText.Encode("model_snapshot_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotRetentionDays = System.Text.Json.JsonEncodedText.Encode("model_snapshot_retention_days"); + private static readonly System.Text.Json.JsonEncodedText PropRenormalizationWindowDays = System.Text.Json.JsonEncodedText.Encode("renormalization_window_days"); + private static readonly System.Text.Json.JsonEncodedText PropResultsIndexName = System.Text.Json.JsonEncodedText.Encode("results_index_name"); + private static readonly System.Text.Json.JsonEncodedText PropResultsRetentionDays = System.Text.Json.JsonEncodedText.Encode("results_retention_days"); + + public override UpdateJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowLazyOpen = default; + LocalJsonProperty propAnalysisConfig = default; + LocalJsonProperty propAnalysisLimits = default; + LocalJsonProperty propBackgroundPersistInterval = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty?> propCustomSettings = default; + LocalJsonProperty propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonProperty propDataDescription = default; + LocalJsonProperty propDatafeedConfig = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propFinishedTime = default; + LocalJsonProperty?> propGroups = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propJobType = default; + LocalJsonProperty propJobVersion = default; + LocalJsonProperty propModelPlotConfig = default; + LocalJsonProperty propModelSnapshotId = default; + LocalJsonProperty propModelSnapshotRetentionDays = default; + LocalJsonProperty propRenormalizationWindowDays = default; + LocalJsonProperty propResultsIndexName = default; + LocalJsonProperty propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryRead(ref reader, options, PropAllowLazyOpen)) + { + continue; + } + + if (propAnalysisConfig.TryRead(ref reader, options, PropAnalysisConfig)) + { + continue; + } + + if (propAnalysisLimits.TryRead(ref reader, options, PropAnalysisLimits)) + { + continue; + } + + if (propBackgroundPersistInterval.TryRead(ref reader, options, PropBackgroundPersistInterval)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propCustomSettings.TryRead(ref reader, options, PropCustomSettings)) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryRead(ref reader, options, PropDailyModelSnapshotRetentionAfterDays)) + { + continue; + } + + if (propDataDescription.TryRead(ref reader, options, PropDataDescription)) + { + continue; + } + + if (propDatafeedConfig.TryRead(ref reader, options, PropDatafeedConfig)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFinishedTime.TryRead(ref reader, options, PropFinishedTime)) + { + continue; + } + + if (propGroups.TryRead(ref reader, options, PropGroups)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propJobType.TryRead(ref reader, options, PropJobType)) + { + continue; + } + + if (propJobVersion.TryRead(ref reader, options, PropJobVersion)) + { + continue; + } + + if (propModelPlotConfig.TryRead(ref reader, options, PropModelPlotConfig)) + { + continue; + } + + if (propModelSnapshotId.TryRead(ref reader, options, PropModelSnapshotId)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryRead(ref reader, options, PropModelSnapshotRetentionDays)) + { + continue; + } + + if (propRenormalizationWindowDays.TryRead(ref reader, options, PropRenormalizationWindowDays)) + { + continue; + } + + if (propResultsIndexName.TryRead(ref reader, options, PropResultsIndexName)) + { + continue; + } + + if (propResultsRetentionDays.TryRead(ref reader, options, PropResultsRetentionDays)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateJobResponse + { + AllowLazyOpen = propAllowLazyOpen.Value +, + AnalysisConfig = propAnalysisConfig.Value +, + AnalysisLimits = propAnalysisLimits.Value +, + BackgroundPersistInterval = propBackgroundPersistInterval.Value +, + CreateTime = propCreateTime.Value +, + CustomSettings = propCustomSettings.Value +, + DailyModelSnapshotRetentionAfterDays = propDailyModelSnapshotRetentionAfterDays.Value +, + DataDescription = propDataDescription.Value +, + DatafeedConfig = propDatafeedConfig.Value +, + Description = propDescription.Value +, + FinishedTime = propFinishedTime.Value +, + Groups = propGroups.Value +, + JobId = propJobId.Value +, + JobType = propJobType.Value +, + JobVersion = propJobVersion.Value +, + ModelPlotConfig = propModelPlotConfig.Value +, + ModelSnapshotId = propModelSnapshotId.Value +, + ModelSnapshotRetentionDays = propModelSnapshotRetentionDays.Value +, + RenormalizationWindowDays = propRenormalizationWindowDays.Value +, + ResultsIndexName = propResultsIndexName.Value +, + ResultsRetentionDays = propResultsRetentionDays.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyOpen, value.AllowLazyOpen); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays); + writer.WriteProperty(options, PropDataDescription, value.DataDescription); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFinishedTime, value.FinishedTime); + writer.WriteProperty(options, PropGroups, value.Groups); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropJobType, value.JobType); + writer.WriteProperty(options, PropJobVersion, value.JobVersion); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateJobResponseConverter))] public sealed partial class UpdateJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_open")] public bool AllowLazyOpen { get; init; } - [JsonInclude, JsonPropertyName("analysis_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.Serverless.Duration? BackgroundPersistInterval { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("custom_settings")] public IReadOnlyDictionary? CustomSettings { get; init; } - [JsonInclude, JsonPropertyName("daily_model_snapshot_retention_after_days")] public long DailyModelSnapshotRetentionAfterDays { get; init; } - [JsonInclude, JsonPropertyName("data_description")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Datafeed? DatafeedConfig { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("finished_time")] public long? FinishedTime { get; init; } - [JsonInclude, JsonPropertyName("groups")] public IReadOnlyCollection? Groups { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("job_type")] public string JobType { get; init; } - [JsonInclude, JsonPropertyName("job_version")] public string JobVersion { get; init; } - [JsonInclude, JsonPropertyName("model_plot_config")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelPlotConfig? ModelPlotConfig { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_id")] public string? ModelSnapshotId { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_retention_days")] public long ModelSnapshotRetentionDays { get; init; } - [JsonInclude, JsonPropertyName("renormalization_window_days")] public long? RenormalizationWindowDays { get; init; } - [JsonInclude, JsonPropertyName("results_index_name")] public string ResultsIndexName { get; init; } - [JsonInclude, JsonPropertyName("results_retention_days")] public long? ResultsRetentionDays { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs index b9b8e2ac13c..e5d86d1aec7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpdateModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropModel = System.Text.Json.JsonEncodedText.Encode("model"); + + public override UpdateModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + LocalJsonProperty propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propModel.TryRead(ref reader, options, PropModel)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateModelSnapshotResponse + { + Acknowledged = propAcknowledged.Value +, + Model = propModel.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropModel, value.Model); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateModelSnapshotResponseConverter))] public sealed partial class UpdateModelSnapshotResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("model")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs index 0b0d55c900d..19d675cb473 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class UpgradeJobSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompleted = System.Text.Json.JsonEncodedText.Encode("completed"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + + public override UpgradeJobSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompleted = default; + LocalJsonProperty propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompleted.TryRead(ref reader, options, PropCompleted)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpgradeJobSnapshotResponse + { + Completed = propCompleted.Value +, + Node = propNode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpgradeJobSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompleted, value.Completed); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeJobSnapshotResponseConverter))] public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse /// When true, this means the task is complete. When false, it is still running. /// /// - [JsonInclude, JsonPropertyName("completed")] public bool Completed { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse /// The ID of the node that the upgrade task was started on if it is still running. In serverless this will be the "serverless". /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } } \ No newline at end of file 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 f911314146a..86cc644fdb9 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 @@ -39,7 +39,7 @@ public sealed partial class ValidateDetectorRequestParameters : RequestParameter /// Validate an anomaly detection job. /// /// -public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfSerializable +public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfTwoWaySerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidateDetector; @@ -49,13 +49,17 @@ public sealed partial class ValidateDetectorRequest : PlainRequest "ml.validate_detector"; - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.Detector Detector { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Detector, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Detector = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs index 9b25cee80ac..cfd780710c8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ValidateDetectorResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ValidateDetectorResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateDetectorResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateDetectorResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateDetectorResponseConverter))] public sealed partial class ValidateDetectorResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ValidateDetectorResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateResponse.g.cs index 338fd739327..eba96de6f5e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MachineLearning/ValidateResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class ValidateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ValidateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateResponseConverter))] public sealed partial class ValidateResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ValidateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiGetResponse.g.cs index 9f71d27fc58..6bc6609ec6a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiGetResponse.g.cs @@ -18,16 +18,69 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class MultiGetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override MultiGetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiGetResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiGetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiGetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiGetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiGetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiGetResponseConverterFactory))] public sealed partial class MultiGetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection> Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchResponse.g.cs index 740fdd5233f..a2a704cc5f9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchResponse.g.cs @@ -18,18 +18,80 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class MultiSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override MultiSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>> propResponses = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchResponse + { + Responses = propResponses.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiSearchResponseConverterFactory))] public sealed partial class MultiSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection> Responses { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchTemplateResponse.g.cs index 8c59f80a1ab..2a2227083fb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiSearchTemplateResponse.g.cs @@ -18,18 +18,80 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class MultiSearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override MultiSearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>> propResponses = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchTemplateResponse + { + Responses = propResponses.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchTemplateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchTemplateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiSearchTemplateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiSearchTemplateResponseConverterFactory))] public sealed partial class MultiSearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection> Responses { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiTermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiTermVectorsResponse.g.cs index 49360764fd3..97d42a42c44 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiTermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/MultiTermVectorsResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class MultiTermVectorsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override MultiTermVectorsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermVectorsResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermVectorsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermVectorsResponseConverter))] public sealed partial class MultiTermVectorsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/HotThreadsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/HotThreadsResponse.g.cs index 12ae0ee843d..ffd1116d103 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/HotThreadsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/HotThreadsResponse.g.cs @@ -18,14 +18,39 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class HotThreadsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override HotThreadsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HotThreadsResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HotThreadsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HotThreadsResponseConverter))] public sealed partial class HotThreadsResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesInfoResponse.g.cs index e4455498428..59427c10aa9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesInfoResponse.g.cs @@ -18,19 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodesInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesInfoResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesInfoResponseConverter))] public sealed partial class NodesInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +93,5 @@ public sealed partial class NodesInfoResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesStatsResponse.g.cs index c61a304dbc5..120a0229cad 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesStatsResponse.g.cs @@ -18,19 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodesStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesStatsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesStatsResponseConverter))] public sealed partial class NodesStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string? ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +93,5 @@ public sealed partial class NodesStatsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesUsageResponse.g.cs index 2b034f606ba..c6d70946abb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Nodes/NodesUsageResponse.g.cs @@ -18,19 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodesUsageResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesUsageResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesUsageResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesUsageResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesUsageResponseConverter))] public sealed partial class NodesUsageResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +93,5 @@ public sealed partial class NodesUsageResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/OpenPointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/OpenPointInTimeResponse.g.cs index b31084c2922..4bca69ed967 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/OpenPointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/OpenPointInTimeResponse.g.cs @@ -18,17 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class OpenPointInTimeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override OpenPointInTimeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propId = default; + LocalJsonProperty propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenPointInTimeResponse + { + Id = propId.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenPointInTimeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenPointInTimeResponseConverter))] public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -36,6 +82,5 @@ public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse /// Shards used to create the PIT /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/PutScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/PutScriptResponse.g.cs index bcbe6d1caf9..be7cb9d04e6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/PutScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/PutScriptResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class PutScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutScriptResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutScriptResponseConverter))] public sealed partial class PutScriptResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutScriptResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs index 110941115db..7c448554d5a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class DeleteRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRuleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRuleResponseConverter))] public sealed partial class DeleteRuleResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteRuleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs index 84c27bf6567..1831206a0e7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class DeleteRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRulesetResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRulesetResponseConverter))] public sealed partial class DeleteRulesetResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteRulesetResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRuleResponse.g.cs index d9ad7a19416..bfca91bf0a7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRuleResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class GetRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropRuleId = System.Text.Json.JsonEncodedText.Encode("rule_id"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GetRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propActions = default; + LocalJsonProperty> propCriteria = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propRuleId = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propRuleId.TryRead(ref reader, options, PropRuleId)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRuleResponse + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + RuleId = propRuleId.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropRuleId, value.RuleId); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRuleResponseConverter))] public sealed partial class GetRuleResponse : ElasticsearchResponse { /// @@ -34,7 +111,6 @@ public sealed partial class GetRuleResponse : ElasticsearchResponse /// The format of this action depends on the rule type. /// /// - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleActions Actions { get; init; } /// @@ -43,10 +119,7 @@ public sealed partial class GetRuleResponse : ElasticsearchResponse /// If multiple criteria are specified for a rule, all criteria must be met for the rule to be applied. /// /// - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria))] public IReadOnlyCollection Criteria { get; init; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; init; } /// @@ -54,7 +127,6 @@ public sealed partial class GetRuleResponse : ElasticsearchResponse /// A unique identifier for the rule. /// /// - [JsonInclude, JsonPropertyName("rule_id")] public string RuleId { get; init; } /// @@ -64,6 +136,5 @@ public sealed partial class GetRuleResponse : ElasticsearchResponse /// exclude will exclude specific documents from search results. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleType Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRulesetResponse.g.cs index d74cfd27de9..aacda151c93 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/GetRulesetResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class GetRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + private static readonly System.Text.Json.JsonEncodedText PropRulesetId = System.Text.Json.JsonEncodedText.Encode("ruleset_id"); + + public override GetRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propRules = default; + LocalJsonProperty propRulesetId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryRead(ref reader, options, PropRules)) + { + continue; + } + + if (propRulesetId.TryRead(ref reader, options, PropRulesetId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRulesetResponse + { + Rules = propRules.Value +, + RulesetId = propRulesetId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRules, value.Rules); + writer.WriteProperty(options, PropRulesetId, value.RulesetId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRulesetResponseConverter))] public sealed partial class GetRulesetResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// Rules associated with the query ruleset. /// /// - [JsonInclude, JsonPropertyName("rules")] public IReadOnlyCollection Rules { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// A unique identifier for the ruleset. /// /// - [JsonInclude, JsonPropertyName("ruleset_id")] public string RulesetId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs index f318fa1003c..94ac6034466 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class ListRulesetsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override ListRulesetsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListRulesetsResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListRulesetsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListRulesetsResponseConverter))] public sealed partial class ListRulesetsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("results")] public IReadOnlyCollection Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleRequest.g.cs index 091422a640c..2843c3bbcde 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,69 @@ public sealed partial class PutRuleRequestParameters : RequestParameters { } +internal sealed partial class PutRuleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PutRuleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propActions = default; + LocalJsonProperty> propCriteria = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRuleRequest + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRuleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query rule. @@ -46,6 +110,7 @@ public sealed partial class PutRuleRequestParameters : RequestParameters /// If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset. /// /// +[JsonConverter(typeof(PutRuleRequestConverter))] public sealed partial class PutRuleRequest : PlainRequest { public PutRuleRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId, Elastic.Clients.Elasticsearch.Serverless.Id ruleId) : base(r => r.Required("ruleset_id", rulesetId).Required("rule_id", ruleId)) @@ -66,7 +131,6 @@ public PutRuleRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId, Ela /// The format of this action depends on the rule type. /// /// - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleActions Actions { get; set; } /// @@ -75,10 +139,7 @@ public PutRuleRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId, Ela /// If multiple criteria are specified for a rule, all criteria must be met for the rule to be applied. /// /// - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } /// @@ -86,7 +147,6 @@ public PutRuleRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId, Ela /// The type of rule. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleResponse.g.cs index aa8c2bc922d..cb6c5adf056 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRuleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class PutRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRuleResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRuleResponseConverter))] public sealed partial class PutRuleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetRequest.g.cs index 824807eba5a..8cd31448b70 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,39 @@ public sealed partial class PutRulesetRequestParameters : RequestParameters { } +internal sealed partial class PutRulesetRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + + public override PutRulesetRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryRead(ref reader, options, PropRules, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRule>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRulesetRequest + { + Rules = propRules.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRulesetRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRules, value.Rules, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRule>)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query ruleset. @@ -47,6 +81,7 @@ public sealed partial class PutRulesetRequestParameters : RequestParameters /// If multiple matching rules pin more than 100 documents, only the first 100 documents are pinned in the order they are specified in the ruleset. /// /// +[JsonConverter(typeof(PutRulesetRequestConverter))] public sealed partial class PutRulesetRequest : PlainRequest { public PutRulesetRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId) : base(r => r.Required("ruleset_id", rulesetId)) @@ -61,8 +96,6 @@ public PutRulesetRequest(Elastic.Clients.Elasticsearch.Serverless.Id rulesetId) internal override string OperationName => "query_rules.put_ruleset"; - [JsonInclude, JsonPropertyName("rules")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRule))] public ICollection Rules { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetResponse.g.cs index 3500ffe97f4..c2f3f334e95 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/PutRulesetResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class PutRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRulesetResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRulesetResponseConverter))] public sealed partial class PutRulesetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/TestResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/TestResponse.g.cs index f2999d2d408..8e606b3ca27 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/TestResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/QueryRules/TestResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class TestResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMatchedRules = System.Text.Json.JsonEncodedText.Encode("matched_rules"); + private static readonly System.Text.Json.JsonEncodedText PropTotalMatchedRules = System.Text.Json.JsonEncodedText.Encode("total_matched_rules"); + + public override TestResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propMatchedRules = default; + LocalJsonProperty propTotalMatchedRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatchedRules.TryRead(ref reader, options, PropMatchedRules)) + { + continue; + } + + if (propTotalMatchedRules.TryRead(ref reader, options, PropTotalMatchedRules)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TestResponse + { + MatchedRules = propMatchedRules.Value +, + TotalMatchedRules = propTotalMatchedRules.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TestResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMatchedRules, value.MatchedRules); + writer.WriteProperty(options, PropTotalMatchedRules, value.TotalMatchedRules); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TestResponseConverter))] public sealed partial class TestResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("matched_rules")] public IReadOnlyCollection MatchedRules { get; init; } - [JsonInclude, JsonPropertyName("total_matched_rules")] public int TotalMatchedRules { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RankEvalResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RankEvalResponse.g.cs index 52a07698d2f..c93cb06e1d3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RankEvalResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RankEvalResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class RankEvalResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDetails = System.Text.Json.JsonEncodedText.Encode("details"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropMetricScore = System.Text.Json.JsonEncodedText.Encode("metric_score"); + + public override RankEvalResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propDetails = default; + LocalJsonProperty> propFailures = default; + LocalJsonProperty propMetricScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetails.TryRead(ref reader, options, PropDetails)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propMetricScore.TryRead(ref reader, options, PropMetricScore)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RankEvalResponse + { + Details = propDetails.Value +, + Failures = propFailures.Value +, + MetricScore = propMetricScore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RankEvalResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetails, value.Details); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropMetricScore, value.MetricScore); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalResponseConverter))] public sealed partial class RankEvalResponse : ElasticsearchResponse { /// @@ -33,9 +90,7 @@ public sealed partial class RankEvalResponse : ElasticsearchResponse /// The details section contains one entry for every query in the original requests section, keyed by the search request id /// /// - [JsonInclude, JsonPropertyName("details")] public IReadOnlyDictionary Details { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyDictionary Failures { get; init; } /// @@ -43,6 +98,5 @@ public sealed partial class RankEvalResponse : ElasticsearchResponse /// The overall evaluation quality calculated by the defined metric /// /// - [JsonInclude, JsonPropertyName("metric_score")] public double MetricScore { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexResponse.g.cs index b6ff9020f2f..471beb7eb6e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexResponse.g.cs @@ -18,46 +18,217 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ReindexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropSliceId = System.Text.Json.JsonEncodedText.Encode("slice_id"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override ReindexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBatches = default; + LocalJsonProperty propCreated = default; + LocalJsonProperty propDeleted = default; + LocalJsonProperty?> propFailures = default; + LocalJsonProperty propNoops = default; + LocalJsonProperty propRequestsPerSecond = default; + LocalJsonProperty propRetries = default; + LocalJsonProperty propSliceId = default; + LocalJsonProperty propTask = default; + LocalJsonProperty propThrottledMillis = default; + LocalJsonProperty propThrottledUntilMillis = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + LocalJsonProperty propTotal = default; + LocalJsonProperty propUpdated = default; + LocalJsonProperty propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propSliceId.TryRead(ref reader, options, PropSliceId)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReindexResponse + { + Batches = propBatches.Value +, + Created = propCreated.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + SliceId = propSliceId.Value +, + Task = propTask.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + Updated = propUpdated.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReindexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropSliceId, value.SliceId); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReindexResponseConverter))] public sealed partial class ReindexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("created")] public long? Created { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Serverless.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.Serverless.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("updated")] public long? Updated { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexRethrottleResponse.g.cs index 19f4f37fe97..ee3a0083b51 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ReindexRethrottleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ReindexRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override ReindexRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReindexRethrottleResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReindexRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReindexRethrottleResponseConverter))] public sealed partial class ReindexRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RenderSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RenderSearchTemplateResponse.g.cs index 0ca6fcf6f2f..dc4a9986fa5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RenderSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/RenderSearchTemplateResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class RenderSearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropTemplateOutput = System.Text.Json.JsonEncodedText.Encode("template_output"); + + public override RenderSearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propTemplateOutput = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTemplateOutput.TryRead(ref reader, options, PropTemplateOutput)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RenderSearchTemplateResponse + { + TemplateOutput = propTemplateOutput.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RenderSearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropTemplateOutput, value.TemplateOutput); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RenderSearchTemplateResponseConverter))] public sealed partial class RenderSearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("template_output")] public IReadOnlyDictionary TemplateOutput { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ScrollResponse.g.cs index 3a5ffc51772..67175517348 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ScrollResponse.g.cs @@ -18,42 +18,212 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ScrollResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override ScrollResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregations = default; + LocalJsonProperty propClusters = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty> propHitsMetadata = default; + LocalJsonProperty propMaxScore = default; + LocalJsonProperty propNumReducePhases = default; + LocalJsonProperty propPitId = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propScrollId = default; + LocalJsonProperty propShards = default; + LocalJsonProperty?> propSuggest = default; + LocalJsonProperty propTerminatedEarly = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScrollResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScrollResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class ScrollResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ScrollResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(ScrollResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(ScrollResponseConverterFactory))] public sealed partial class ScrollResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.Serverless.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.Serverless.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchMvtRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchMvtRequest.g.cs index f66e7e1f320..531e63d53f5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchMvtRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchMvtRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,169 @@ public sealed partial class SearchMvtRequestParameters : RequestParameters { } +internal sealed partial class SearchMvtRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggs = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropBuffer = System.Text.Json.JsonEncodedText.Encode("buffer"); + private static readonly System.Text.Json.JsonEncodedText PropExactBounds = System.Text.Json.JsonEncodedText.Encode("exact_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropExtent = System.Text.Json.JsonEncodedText.Encode("extent"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropGridAgg = System.Text.Json.JsonEncodedText.Encode("grid_agg"); + private static readonly System.Text.Json.JsonEncodedText PropGridPrecision = System.Text.Json.JsonEncodedText.Encode("grid_precision"); + private static readonly System.Text.Json.JsonEncodedText PropGridType = System.Text.Json.JsonEncodedText.Encode("grid_type"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropWithLabels = System.Text.Json.JsonEncodedText.Encode("with_labels"); + + public override SearchMvtRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggs = default; + LocalJsonProperty propBuffer = default; + LocalJsonProperty propExactBounds = default; + LocalJsonProperty propExtent = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propGridAgg = default; + LocalJsonProperty propGridPrecision = default; + LocalJsonProperty propGridType = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propTrackTotalHits = default; + LocalJsonProperty propWithLabels = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggs.TryRead(ref reader, options, PropAggs)) + { + continue; + } + + if (propBuffer.TryRead(ref reader, options, PropBuffer)) + { + continue; + } + + if (propExactBounds.TryRead(ref reader, options, PropExactBounds)) + { + continue; + } + + if (propExtent.TryRead(ref reader, options, PropExtent)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propGridAgg.TryRead(ref reader, options, PropGridAgg)) + { + continue; + } + + if (propGridPrecision.TryRead(ref reader, options, PropGridPrecision)) + { + continue; + } + + if (propGridType.TryRead(ref reader, options, PropGridType)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } + + if (propWithLabels.TryRead(ref reader, options, PropWithLabels)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchMvtRequest + { + Aggs = propAggs.Value +, + Buffer = propBuffer.Value +, + ExactBounds = propExactBounds.Value +, + Extent = propExtent.Value +, + Fields = propFields.Value +, + GridAgg = propGridAgg.Value +, + GridPrecision = propGridPrecision.Value +, + GridType = propGridType.Value +, + Query = propQuery.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + TrackTotalHits = propTrackTotalHits.Value +, + WithLabels = propWithLabels.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchMvtRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggs, value.Aggs); + writer.WriteProperty(options, PropBuffer, value.Buffer); + writer.WriteProperty(options, PropExactBounds, value.ExactBounds); + writer.WriteProperty(options, PropExtent, value.Extent); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropGridAgg, value.GridAgg); + writer.WriteProperty(options, PropGridPrecision, value.GridPrecision); + writer.WriteProperty(options, PropGridType, value.GridType); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropWithLabels, value.WithLabels); + writer.WriteEndObject(); + } +} + /// /// /// Search a vector tile. @@ -42,6 +206,7 @@ public sealed partial class SearchMvtRequestParameters : RequestParameters /// Search a vector tile for geospatial values. /// /// +[JsonConverter(typeof(SearchMvtRequestConverter))] public sealed partial class SearchMvtRequest : PlainRequest { public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices, Elastic.Clients.Elasticsearch.Serverless.Field field, int zoom, int x, int y) : base(r => r.Required("index", indices).Required("field", field).Required("zoom", zoom).Required("x", x).Required("y", y)) @@ -91,7 +256,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// /// /// - [JsonInclude, JsonPropertyName("aggs")] public IDictionary? Aggs { get; set; } /// @@ -100,7 +264,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// to avoid outline artifacts from geometries that extend past the extent of the tile. /// /// - [JsonInclude, JsonPropertyName("buffer")] public int? Buffer { get; set; } /// @@ -112,7 +275,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// bounding box may be larger than the vector tile. /// /// - [JsonInclude, JsonPropertyName("exact_bounds")] public bool? ExactBounds { get; set; } /// @@ -120,7 +282,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Size, in pixels, of a side of the tile. Vector tiles are square with equal sides. /// /// - [JsonInclude, JsonPropertyName("extent")] public int? Extent { get; set; } /// @@ -130,8 +291,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// values may return inconsistent results. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -139,7 +298,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Aggregation used to create a grid for the field. /// /// - [JsonInclude, JsonPropertyName("grid_agg")] public Elastic.Clients.Elasticsearch.Serverless.Core.SearchMvt.GridAggregationType? GridAgg { get; set; } /// @@ -149,7 +307,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// don’t include the aggs layer. /// /// - [JsonInclude, JsonPropertyName("grid_precision")] public int? GridPrecision { get; set; } /// @@ -160,7 +317,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// of the cell. /// /// - [JsonInclude, JsonPropertyName("grid_type")] public Elastic.Clients.Elasticsearch.Serverless.Core.SearchMvt.GridType? GridType { get; set; } /// @@ -168,7 +324,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// Query DSL used to filter documents for the search. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } /// @@ -177,7 +332,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -186,7 +340,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// If 0, results don’t include the hits layer. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -196,8 +349,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// from longest to shortest. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } /// @@ -207,7 +358,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -216,7 +366,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Serverless.Indices indices /// suggested label positions for the original features. /// /// - [JsonInclude, JsonPropertyName("with_labels")] public bool? WithLabels { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs index d7dfb6182ad..4e82a540230 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -264,422 +265,356 @@ public sealed partial class SearchRequestParameters : RequestParameters public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } } -internal sealed partial class SearchRequestConverter : JsonConverter +internal sealed partial class SearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRetriever = System.Text.Json.JsonEncodedText.Encode("retriever"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propCollapse = default; + LocalJsonProperty?> propDocvalueFields = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty?> propExt = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty>?> propIndicesBoost = default; + LocalJsonProperty?> propKnn = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propPit = default; + LocalJsonProperty propPostFilter = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propRescore = default; + LocalJsonProperty propRetriever = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSeqNoPrimaryTerm = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propSlice = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty?> propStats = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propSuggest = default; + LocalJsonProperty propTerminateAfter = default; + LocalJsonProperty propTimeout = default; + LocalJsonProperty propTrackScores = default; + LocalJsonProperty propTrackTotalHits = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "retriever") - { - variant.Retriever = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slice") - { - variant.Slice = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>))) + { + continue; + } - if (value.Retriever is not null) - { - writer.WritePropertyName("retriever"); - JsonSerializer.Serialize(writer, value.Retriever, options); - } + if (propRetriever.TryRead(ref reader, options, PropRetriever)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchRequest + { + Aggregations = propAggregations.Value + , + Collapse = propCollapse.Value + , + DocvalueFields = propDocvalueFields.Value + , + Explain = propExplain.Value + , + Ext = propExt.Value + , + Fields = propFields.Value + , + From = propFrom.Value + , + Highlight = propHighlight.Value + , + IndicesBoost = propIndicesBoost.Value + , + Knn = propKnn.Value + , + MinScore = propMinScore.Value + , + Pit = propPit.Value + , + PostFilter = propPostFilter.Value + , + Profile = propProfile.Value + , + Query = propQuery.Value + , + Rescore = propRescore.Value + , + Retriever = propRetriever.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + SearchAfter = propSearchAfter.Value + , + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value + , + Size = propSize.Value + , + Slice = propSlice.Value + , + Sort = propSort.Value + , + Source = propSource.Value + , + Stats = propStats.Value + , + StoredFields = propStoredFields.Value + , + Suggest = propSuggest.Value + , + TerminateAfter = propTerminateAfter.Value + , + Timeout = propTimeout.Value + , + TrackScores = propTrackScores.Value + , + TrackTotalHits = propTrackTotalHits.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRescore, value.Rescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRetriever, value.Retriever); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } @@ -720,7 +655,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -728,7 +662,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, returns partial results if there are shard request timeouts or shard failures. If false, returns an error with no partial results. /// /// - [JsonIgnore] public bool? AllowPartialSearchResults { get => Q("allow_partial_search_results"); set => Q("allow_partial_search_results", value); } /// @@ -737,7 +670,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public string? Analyzer { get => Q("analyzer"); set => Q("analyzer", value); } /// @@ -746,7 +678,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public bool? AnalyzeWildcard { get => Q("analyze_wildcard"); set => Q("analyze_wildcard", value); } /// @@ -755,7 +686,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. /// /// - [JsonIgnore] public long? BatchedReduceSize { get => Q("batched_reduce_size"); set => Q("batched_reduce_size", value); } /// @@ -763,7 +693,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. /// /// - [JsonIgnore] public bool? CcsMinimizeRoundtrips { get => Q("ccs_minimize_roundtrips"); set => Q("ccs_minimize_roundtrips", value); } /// @@ -772,7 +701,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -781,7 +709,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public string? Df { get => Q("df"); set => Q("df", value); } /// @@ -791,7 +718,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Supports comma-separated values, such as open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -799,7 +725,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, concrete, expanded or aliased indices will be ignored when frozen. /// /// - [JsonIgnore] public bool? IgnoreThrottled { get => Q("ignore_throttled"); set => Q("ignore_throttled", value); } /// @@ -807,7 +732,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If false, the request returns an error if it targets a missing or closed index. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -816,7 +740,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public bool? Lenient { get => Q("lenient"); set => Q("lenient", value); } /// @@ -825,7 +748,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. /// /// - [JsonIgnore] public long? MaxConcurrentShardRequests { get => Q("max_concurrent_shard_requests"); set => Q("max_concurrent_shard_requests", value); } /// @@ -840,7 +762,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// <custom-string> (any string that does not start with _) to route searches with the same <custom-string> to the same shards in the same order. /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -853,7 +774,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// the primary sort of the query targets an indexed field. /// /// - [JsonIgnore] public long? PreFilterShardSize { get => Q("pre_filter_shard_size"); set => Q("pre_filter_shard_size", value); } /// @@ -862,7 +782,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing. /// /// - [JsonIgnore] public string? QueryLuceneSyntax { get => Q("q"); set => Q("q", value); } /// @@ -871,7 +790,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defaults to index level settings. /// /// - [JsonIgnore] public bool? RequestCache { get => Q("request_cache"); set => Q("request_cache", value); } /// @@ -879,7 +797,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Indicates whether hits.total should be rendered as an integer or an object in the rest search response. /// /// - [JsonIgnore] public bool? RestTotalHitsAsInt { get => Q("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); } /// @@ -887,7 +804,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -897,7 +813,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// You can change this limit using the search.max_keep_alive cluster-level setting. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Scroll { get => Q("scroll"); set => Q("scroll", value); } /// @@ -905,7 +820,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// How distributed term frequencies are calculated for relevance scoring. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -915,7 +829,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -926,7 +839,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -934,7 +846,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -943,7 +854,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -952,7 +862,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public long? SuggestSize { get => Q("suggest_size"); set => Q("suggest_size", value); } /// @@ -961,7 +870,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public string? SuggestText { get => Q("suggest_text"); set => Q("suggest_text", value); } /// @@ -969,7 +877,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, aggregation and suggester names are be prefixed by their respective types in the response. /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -977,7 +884,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defines the aggregations that are run as part of the search request. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -985,7 +891,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Collapses search results the values of the specified field. /// /// - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -994,7 +899,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// The request returns doc values for field names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -1002,7 +906,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -1010,7 +913,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -1019,7 +921,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// The request returns values for field names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -1030,7 +931,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -1038,7 +938,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results. /// /// - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; set; } /// @@ -1046,7 +945,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -1054,8 +952,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -1064,7 +960,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Documents with a lower _score are not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -1073,7 +968,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If you provide a PIT, you cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.PointInTimeReference? Pit { get; set; } /// @@ -1083,7 +977,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// A post filter has no impact on the aggregation results. /// /// - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? PostFilter { get; set; } /// @@ -1092,7 +985,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// NOTE: This is a debugging tool and adds significant overhead to search execution. /// /// - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -1100,7 +992,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } /// @@ -1108,8 +999,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the query and post_filter phases. /// /// - [JsonInclude, JsonPropertyName("rescore")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1117,7 +1006,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such as query and knn. /// /// - [JsonInclude, JsonPropertyName("retriever")] public Elastic.Clients.Elasticsearch.Serverless.Retriever? Retriever { get; set; } /// @@ -1126,7 +1014,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// These fields take precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1134,7 +1021,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Retrieve a script evaluation (based on different fields) for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -1142,7 +1028,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Used to retrieve the next page of hits using a set of sort values from the previous page. /// /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -1150,7 +1035,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, returns sequence number and primary term of the last modification of each hit. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -1160,7 +1044,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -1168,7 +1051,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Can be used to split a scrolled search into multiple slices that can be consumed independently. /// /// - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.Serverless.SlicedScroll? Slice { get; set; } /// @@ -1176,8 +1058,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// A comma-separated list of <field>:<direction> pairs. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1186,7 +1066,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// These fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// @@ -1196,7 +1075,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// You can retrieve these stats using the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1207,8 +1085,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// You can pass _source: true to return both source fields and stored fields in the search response. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } /// @@ -1216,7 +1092,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defines a suggester that provides similar looking terms based on a provided text. /// /// - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Suggester? Suggest { get; set; } /// @@ -1231,7 +1106,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If set to 0 (default), the query does not terminate early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1241,7 +1115,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1249,7 +1122,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, calculate and return document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -1259,7 +1131,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If false, the response does not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1267,7 +1138,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Serverless.Indices? indices) /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchResponse.g.cs index 151530f6fec..7c0674663f6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchResponse.g.cs @@ -18,42 +18,212 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class SearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override SearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregations = default; + LocalJsonProperty propClusters = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty> propHitsMetadata = default; + LocalJsonProperty propMaxScore = default; + LocalJsonProperty propNumReducePhases = default; + LocalJsonProperty propPitId = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propScrollId = default; + LocalJsonProperty propShards = default; + LocalJsonProperty?> propSuggest = default; + LocalJsonProperty propTerminatedEarly = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SearchResponseConverterFactory))] public sealed partial class SearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.Serverless.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.Serverless.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchTemplateResponse.g.cs index 16e9c64ac63..a3eaf51042b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchTemplateResponse.g.cs @@ -18,42 +18,212 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class SearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override SearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregations = default; + LocalJsonProperty propClusters = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty> propHits = default; + LocalJsonProperty propMaxScore = default; + LocalJsonProperty propNumReducePhases = default; + LocalJsonProperty propPitId = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propScrollId = default; + LocalJsonProperty propShards = default; + LocalJsonProperty?> propSuggest = default; + LocalJsonProperty propTerminatedEarly = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchTemplateResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + Hits = propHits.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchTemplateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchTemplateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SearchTemplateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SearchTemplateResponseConverterFactory))] public sealed partial class SearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.Serverless.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HitsMetadata Hits { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.Serverless.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ActivateUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ActivateUserProfileResponse.g.cs index eef852bd9c6..b784d6983e2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ActivateUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ActivateUserProfileResponse.g.cs @@ -18,28 +18,118 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ActivateUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("_doc"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropLabels = System.Text.Json.JsonEncodedText.Encode("labels"); + private static readonly System.Text.Json.JsonEncodedText PropLastSynchronized = System.Text.Json.JsonEncodedText.Encode("last_synchronized"); + private static readonly System.Text.Json.JsonEncodedText PropUid = System.Text.Json.JsonEncodedText.Encode("uid"); + private static readonly System.Text.Json.JsonEncodedText PropUser = System.Text.Json.JsonEncodedText.Encode("user"); + + public override ActivateUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propData = default; + LocalJsonProperty propDoc = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty> propLabels = default; + LocalJsonProperty propLastSynchronized = default; + LocalJsonProperty propUid = default; + LocalJsonProperty propUser = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData)) + { + continue; + } + + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propLabels.TryRead(ref reader, options, PropLabels)) + { + continue; + } + + if (propLastSynchronized.TryRead(ref reader, options, PropLastSynchronized)) + { + continue; + } + + if (propUid.TryRead(ref reader, options, PropUid)) + { + continue; + } + + if (propUser.TryRead(ref reader, options, PropUser)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ActivateUserProfileResponse + { + Data = propData.Value +, + Doc = propDoc.Value +, + Enabled = propEnabled.Value +, + Labels = propLabels.Value +, + LastSynchronized = propLastSynchronized.Value +, + Uid = propUid.Value +, + User = propUser.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ActivateUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropLabels, value.Labels); + writer.WriteProperty(options, PropLastSynchronized, value.LastSynchronized); + writer.WriteProperty(options, PropUid, value.Uid); + writer.WriteProperty(options, PropUser, value.User); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ActivateUserProfileResponseConverter))] public sealed partial class ActivateUserProfileResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data")] public IReadOnlyDictionary Data { get; init; } - [JsonInclude, JsonPropertyName("_doc")] public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileHitMetadata Doc { get; init; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; init; } - [JsonInclude, JsonPropertyName("labels")] public IReadOnlyDictionary Labels { get; init; } - [JsonInclude, JsonPropertyName("last_synchronized")] public long LastSynchronized { get; init; } - [JsonInclude, JsonPropertyName("uid")] public string Uid { get; init; } - [JsonInclude, JsonPropertyName("user")] public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileUser User { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/AuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/AuthenticateResponse.g.cs index 3da609f9d34..da0a04c9625 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/AuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/AuthenticateResponse.g.cs @@ -18,36 +18,162 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class AuthenticateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropAuthenticationRealm = System.Text.Json.JsonEncodedText.Encode("authentication_realm"); + private static readonly System.Text.Json.JsonEncodedText PropAuthenticationType = System.Text.Json.JsonEncodedText.Encode("authentication_type"); + private static readonly System.Text.Json.JsonEncodedText PropEmail = System.Text.Json.JsonEncodedText.Encode("email"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFullName = System.Text.Json.JsonEncodedText.Encode("full_name"); + private static readonly System.Text.Json.JsonEncodedText PropLookupRealm = System.Text.Json.JsonEncodedText.Encode("lookup_realm"); + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override AuthenticateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propApiKey = default; + LocalJsonProperty propAuthenticationRealm = default; + LocalJsonProperty propAuthenticationType = default; + LocalJsonProperty propEmail = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty propFullName = default; + LocalJsonProperty propLookupRealm = default; + LocalJsonProperty> propMetadata = default; + LocalJsonProperty> propRoles = default; + LocalJsonProperty propToken = default; + LocalJsonProperty propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propAuthenticationRealm.TryRead(ref reader, options, PropAuthenticationRealm)) + { + continue; + } + + if (propAuthenticationType.TryRead(ref reader, options, PropAuthenticationType)) + { + continue; + } + + if (propEmail.TryRead(ref reader, options, PropEmail)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFullName.TryRead(ref reader, options, PropFullName)) + { + continue; + } + + if (propLookupRealm.TryRead(ref reader, options, PropLookupRealm)) + { + continue; + } + + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AuthenticateResponse + { + ApiKey = propApiKey.Value +, + AuthenticationRealm = propAuthenticationRealm.Value +, + AuthenticationType = propAuthenticationType.Value +, + Email = propEmail.Value +, + Enabled = propEnabled.Value +, + FullName = propFullName.Value +, + LookupRealm = propLookupRealm.Value +, + Metadata = propMetadata.Value +, + Roles = propRoles.Value +, + Token = propToken.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AuthenticateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropAuthenticationRealm, value.AuthenticationRealm); + writer.WriteProperty(options, PropAuthenticationType, value.AuthenticationType); + writer.WriteProperty(options, PropEmail, value.Email); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFullName, value.FullName); + writer.WriteProperty(options, PropLookupRealm, value.LookupRealm); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AuthenticateResponseConverter))] public sealed partial class AuthenticateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_key")] public Elastic.Clients.Elasticsearch.Serverless.Security.AuthenticateApiKey? ApiKey { get; init; } - [JsonInclude, JsonPropertyName("authentication_realm")] public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo AuthenticationRealm { get; init; } - [JsonInclude, JsonPropertyName("authentication_type")] public string AuthenticationType { get; init; } - [JsonInclude, JsonPropertyName("email")] public string? Email { get; init; } - [JsonInclude, JsonPropertyName("enabled")] public bool Enabled { get; init; } - [JsonInclude, JsonPropertyName("full_name")] public string? FullName { get; init; } - [JsonInclude, JsonPropertyName("lookup_realm")] public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo LookupRealm { get; init; } - [JsonInclude, JsonPropertyName("metadata")] public IReadOnlyDictionary Metadata { get; init; } - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection Roles { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Serverless.Security.AuthenticateToken? Token { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs index 4334b626ee3..ed05f391e6e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class BulkDeleteRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropNotFound = System.Text.Json.JsonEncodedText.Encode("not_found"); + + public override BulkDeleteRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propDeleted = default; + LocalJsonProperty propErrors = default; + LocalJsonProperty?> propNotFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propNotFound.TryRead(ref reader, options, PropNotFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkDeleteRoleResponse + { + Deleted = propDeleted.Value +, + Errors = propErrors.Value +, + NotFound = propNotFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkDeleteRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropNotFound, value.NotFound); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkDeleteRoleResponseConverter))] public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Array of deleted roles /// /// - [JsonInclude, JsonPropertyName("deleted")] public IReadOnlyCollection? Deleted { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Present if any deletes resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Serverless.Security.BulkError? Errors { get; init; } /// @@ -49,6 +104,5 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Array of roles that could not be found /// /// - [JsonInclude, JsonPropertyName("not_found")] public IReadOnlyCollection? NotFound { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkPutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkPutRoleResponse.g.cs index 85ff7db5a44..5b7b22eb699 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkPutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/BulkPutRoleResponse.g.cs @@ -18,14 +18,81 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class BulkPutRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropNoop = System.Text.Json.JsonEncodedText.Encode("noop"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override BulkPutRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propCreated = default; + LocalJsonProperty propErrors = default; + LocalJsonProperty?> propNoop = default; + LocalJsonProperty?> propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propNoop.TryRead(ref reader, options, PropNoop)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkPutRoleResponse + { + Created = propCreated.Value +, + Errors = propErrors.Value +, + Noop = propNoop.Value +, + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkPutRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropNoop, value.Noop); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkPutRoleResponseConverter))] public sealed partial class BulkPutRoleResponse : ElasticsearchResponse { /// @@ -33,7 +100,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of created roles /// /// - [JsonInclude, JsonPropertyName("created")] public IReadOnlyCollection? Created { get; init; } /// @@ -41,7 +107,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Present if any updates resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Serverless.Security.BulkError? Errors { get; init; } /// @@ -49,7 +114,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of role names without any changes /// /// - [JsonInclude, JsonPropertyName("noop")] public IReadOnlyCollection? Noop { get; init; } /// @@ -57,6 +121,5 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of updated roles /// /// - [JsonInclude, JsonPropertyName("updated")] public IReadOnlyCollection? Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs index e7dd4705bee..b19e36c7f3e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ClearApiKeyCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearApiKeyCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearApiKeyCacheResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearApiKeyCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearApiKeyCacheResponseConverter))] public sealed partial class ClearApiKeyCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs index 80153dbf93b..811c76038db 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ClearCachedPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedPrivilegesResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedPrivilegesResponseConverter))] public sealed partial class ClearCachedPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs index efe1c3411eb..787e90930e8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ClearCachedRealmsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedRealmsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedRealmsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedRealmsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedRealmsResponseConverter))] public sealed partial class ClearCachedRealmsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRolesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRolesResponse.g.cs index e28b91f8337..b44c07eb8ef 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRolesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedRolesResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ClearCachedRolesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedRolesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedRolesResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedRolesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedRolesResponseConverter))] public sealed partial class ClearCachedRolesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs index a97f7495f65..2d9850c62b1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class ClearCachedServiceTokensResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedServiceTokensResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propClusterName = default; + LocalJsonProperty> propNodes = default; + LocalJsonProperty propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedServiceTokensResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedServiceTokensResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedServiceTokensResponseConverter))] public sealed partial class ClearCachedServiceTokensResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.Serverless.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateApiKeyResponse.g.cs index 841689b990c..e0b1f0a39de 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateApiKeyResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class CreateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropEncoded = System.Text.Json.JsonEncodedText.Encode("encoded"); + private static readonly System.Text.Json.JsonEncodedText PropExpiration = System.Text.Json.JsonEncodedText.Encode("expiration"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override CreateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propApiKey = default; + LocalJsonProperty propEncoded = default; + LocalJsonProperty propExpiration = default; + LocalJsonProperty propId = default; + LocalJsonProperty propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propEncoded.TryRead(ref reader, options, PropEncoded)) + { + continue; + } + + if (propExpiration.TryRead(ref reader, options, PropExpiration)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropEncoded, value.Encoded); + writer.WriteProperty(options, PropExpiration, value.Expiration); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateApiKeyResponseConverter))] public sealed partial class CreateApiKeyResponse : ElasticsearchResponse { /// @@ -33,7 +110,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Generated API key. /// /// - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } /// @@ -43,7 +119,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// by a colon (:). /// /// - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } /// @@ -51,7 +126,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Expiration in milliseconds for the API key. /// /// - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } /// @@ -59,7 +133,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Unique ID for this API key. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -67,6 +140,5 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Specifies the name for this API key. /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateServiceTokenResponse.g.cs index 14ddc24ddc3..35f6970c439 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/CreateServiceTokenResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class CreateServiceTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + + public override CreateServiceTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCreated = default; + LocalJsonProperty propToken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateServiceTokenResponse + { + Created = propCreated.Value +, + Token = propToken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateServiceTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateServiceTokenResponseConverter))] public sealed partial class CreateServiceTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool Created { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Serverless.Security.ServiceToken Token { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs index 69ec38d8224..042febaaa01 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class DeleteRoleMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteRoleMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRoleMappingResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRoleMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRoleMappingResponseConverter))] public sealed partial class DeleteRoleMappingResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleResponse.g.cs index e7fc61a464e..a9aee7f7980 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteRoleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class DeleteRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRoleResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRoleResponseConverter))] public sealed partial class DeleteRoleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs index 26b35f9f977..7a546a04d0a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class DeleteServiceTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteServiceTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteServiceTokenResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteServiceTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteServiceTokenResponseConverter))] public sealed partial class DeleteServiceTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DisableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DisableUserProfileResponse.g.cs index 13e6c139b7f..40a56b6b93c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DisableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/DisableUserProfileResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class DisableUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DisableUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DisableUserProfileResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DisableUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DisableUserProfileResponseConverter))] public sealed partial class DisableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DisableUserProfileResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/EnableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/EnableUserProfileResponse.g.cs index 4296ea9afc1..9d821de206d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/EnableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/EnableUserProfileResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class EnableUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override EnableUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnableUserProfileResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnableUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnableUserProfileResponseConverter))] public sealed partial class EnableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class EnableUserProfileResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetApiKeyResponse.g.cs index 38a73ca81a9..8a28a5ca31d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetApiKeyResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKeys = System.Text.Json.JsonEncodedText.Encode("api_keys"); + + public override GetApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKeys.TryRead(ref reader, options, PropApiKeys)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetApiKeyResponse + { + ApiKeys = propApiKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKeys, value.ApiKeys); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetApiKeyResponseConverter))] public sealed partial class GetApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_keys")] public IReadOnlyCollection ApiKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs index 289a4f1da56..9d20abaf26f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetBuiltinPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + + public override GetBuiltinPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propCluster = default; + LocalJsonProperty> propIndex = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBuiltinPrivilegesResponse + { + Cluster = propCluster.Value +, + Index = propIndex.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBuiltinPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBuiltinPrivilegesResponseConverter))] public sealed partial class GetBuiltinPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyCollection Cluster { get; init; } - [JsonInclude, JsonPropertyName("index")] public IReadOnlyCollection Index { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs index 02af7395fcc..8107c23ad47 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs @@ -18,17 +18,83 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetServiceCredentialsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropNodesCredentials = System.Text.Json.JsonEncodedText.Encode("nodes_credentials"); + private static readonly System.Text.Json.JsonEncodedText PropServiceAccount = System.Text.Json.JsonEncodedText.Encode("service_account"); + private static readonly System.Text.Json.JsonEncodedText PropTokens = System.Text.Json.JsonEncodedText.Encode("tokens"); + + public override GetServiceCredentialsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty propNodesCredentials = default; + LocalJsonProperty propServiceAccount = default; + LocalJsonProperty>> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propNodesCredentials.TryRead(ref reader, options, PropNodesCredentials)) + { + continue; + } + + if (propServiceAccount.TryRead(ref reader, options, PropServiceAccount)) + { + continue; + } + + if (propTokens.TryRead(ref reader, options, PropTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetServiceCredentialsResponse + { + Count = propCount.Value +, + NodesCredentials = propNodesCredentials.Value +, + ServiceAccount = propServiceAccount.Value +, + Tokens = propTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetServiceCredentialsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropNodesCredentials, value.NodesCredentials); + writer.WriteProperty(options, PropServiceAccount, value.ServiceAccount); + writer.WriteProperty(options, PropTokens, value.Tokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetServiceCredentialsResponseConverter))] public sealed partial class GetServiceCredentialsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,10 +102,7 @@ public sealed partial class GetServiceCredentialsResponse : ElasticsearchRespons /// Contains service account credentials collected from all nodes of the cluster /// /// - [JsonInclude, JsonPropertyName("nodes_credentials")] public Elastic.Clients.Elasticsearch.Serverless.Security.NodesCredentials NodesCredentials { get; init; } - [JsonInclude, JsonPropertyName("service_account")] public string ServiceAccount { get; init; } - [JsonInclude, JsonPropertyName("tokens")] public IReadOnlyDictionary> Tokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetTokenResponse.g.cs index 36728c4b664..e85cd4a3904 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetTokenResponse.g.cs @@ -18,28 +18,118 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + private static readonly System.Text.Json.JsonEncodedText PropAuthentication = System.Text.Json.JsonEncodedText.Encode("authentication"); + private static readonly System.Text.Json.JsonEncodedText PropExpiresIn = System.Text.Json.JsonEncodedText.Encode("expires_in"); + private static readonly System.Text.Json.JsonEncodedText PropKerberosAuthenticationResponseToken = System.Text.Json.JsonEncodedText.Encode("kerberos_authentication_response_token"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText PropScope = System.Text.Json.JsonEncodedText.Encode("scope"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GetTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAccessToken = default; + LocalJsonProperty propAuthentication = default; + LocalJsonProperty propExpiresIn = default; + LocalJsonProperty propKerberosAuthenticationResponseToken = default; + LocalJsonProperty propRefreshToken = default; + LocalJsonProperty propScope = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryRead(ref reader, options, PropAccessToken)) + { + continue; + } + + if (propAuthentication.TryRead(ref reader, options, PropAuthentication)) + { + continue; + } + + if (propExpiresIn.TryRead(ref reader, options, PropExpiresIn)) + { + continue; + } + + if (propKerberosAuthenticationResponseToken.TryRead(ref reader, options, PropKerberosAuthenticationResponseToken)) + { + continue; + } + + if (propRefreshToken.TryRead(ref reader, options, PropRefreshToken)) + { + continue; + } + + if (propScope.TryRead(ref reader, options, PropScope)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTokenResponse + { + AccessToken = propAccessToken.Value +, + Authentication = propAuthentication.Value +, + ExpiresIn = propExpiresIn.Value +, + KerberosAuthenticationResponseToken = propKerberosAuthenticationResponseToken.Value +, + RefreshToken = propRefreshToken.Value +, + Scope = propScope.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccessToken, value.AccessToken); + writer.WriteProperty(options, PropAuthentication, value.Authentication); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn); + writer.WriteProperty(options, PropKerberosAuthenticationResponseToken, value.KerberosAuthenticationResponseToken); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken); + writer.WriteProperty(options, PropScope, value.Scope); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTokenResponseConverter))] public sealed partial class GetTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("access_token")] public string AccessToken { get; init; } - [JsonInclude, JsonPropertyName("authentication")] public Elastic.Clients.Elasticsearch.Serverless.Security.AuthenticatedUser Authentication { get; init; } - [JsonInclude, JsonPropertyName("expires_in")] public long ExpiresIn { get; init; } - [JsonInclude, JsonPropertyName("kerberos_authentication_response_token")] public string? KerberosAuthenticationResponseToken { get; init; } - [JsonInclude, JsonPropertyName("refresh_token")] public string? RefreshToken { get; init; } - [JsonInclude, JsonPropertyName("scope")] public string? Scope { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs index 308ab397b53..f98887f6a19 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs @@ -18,24 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetUserPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApplications = System.Text.Json.JsonEncodedText.Encode("applications"); + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropRunAs = System.Text.Json.JsonEncodedText.Encode("run_as"); + + public override GetUserPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propApplications = default; + LocalJsonProperty> propCluster = default; + LocalJsonProperty> propGlobal = default; + LocalJsonProperty> propIndices = default; + LocalJsonProperty> propRunAs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplications.TryRead(ref reader, options, PropApplications)) + { + continue; + } + + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propGlobal.TryRead(ref reader, options, PropGlobal)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propRunAs.TryRead(ref reader, options, PropRunAs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetUserPrivilegesResponse + { + Applications = propApplications.Value +, + Cluster = propCluster.Value +, + Global = propGlobal.Value +, + Indices = propIndices.Value +, + RunAs = propRunAs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetUserPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApplications, value.Applications); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropGlobal, value.Global); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropRunAs, value.RunAs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetUserPrivilegesResponseConverter))] public sealed partial class GetUserPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("applications")] public IReadOnlyCollection Applications { get; init; } - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyCollection Cluster { get; init; } - [JsonInclude, JsonPropertyName("global")] public IReadOnlyCollection Global { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("run_as")] public IReadOnlyCollection RunAs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserProfileResponse.g.cs index de77684beab..538f65c7fd3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GetUserProfileResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GetUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropProfiles = System.Text.Json.JsonEncodedText.Encode("profiles"); + + public override GetUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propErrors = default; + LocalJsonProperty> propProfiles = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propProfiles.TryRead(ref reader, options, PropProfiles)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetUserProfileResponse + { + Errors = propErrors.Value +, + Profiles = propProfiles.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropProfiles, value.Profiles); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetUserProfileResponseConverter))] public sealed partial class GetUserProfileResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Serverless.Security.GetUserProfileErrors? Errors { get; init; } - [JsonInclude, JsonPropertyName("profiles")] public IReadOnlyCollection Profiles { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GrantApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GrantApiKeyResponse.g.cs index 60f9d7f83b5..f720b37ed2e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GrantApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/GrantApiKeyResponse.g.cs @@ -18,24 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class GrantApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropEncoded = System.Text.Json.JsonEncodedText.Encode("encoded"); + private static readonly System.Text.Json.JsonEncodedText PropExpiration = System.Text.Json.JsonEncodedText.Encode("expiration"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override GrantApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propApiKey = default; + LocalJsonProperty propEncoded = default; + LocalJsonProperty propExpiration = default; + LocalJsonProperty propId = default; + LocalJsonProperty propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propEncoded.TryRead(ref reader, options, PropEncoded)) + { + continue; + } + + if (propExpiration.TryRead(ref reader, options, PropExpiration)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GrantApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GrantApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropEncoded, value.Encoded); + writer.WriteProperty(options, PropExpiration, value.Expiration); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GrantApiKeyResponseConverter))] public sealed partial class GrantApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesResponse.g.cs index 4411a6e4215..92951110a4f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesResponse.g.cs @@ -18,25 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class HasPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApplication = System.Text.Json.JsonEncodedText.Encode("application"); + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropHasAllRequested = System.Text.Json.JsonEncodedText.Encode("has_all_requested"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override HasPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>>> propApplication = default; + LocalJsonProperty> propCluster = default; + LocalJsonProperty propHasAllRequested = default; + LocalJsonProperty>> propIndex = default; + LocalJsonProperty propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplication.TryRead(ref reader, options, PropApplication)) + { + continue; + } + + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propHasAllRequested.TryRead(ref reader, options, PropHasAllRequested)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HasPrivilegesResponse + { + Application = propApplication.Value +, + Cluster = propCluster.Value +, + HasAllRequested = propHasAllRequested.Value +, + Index = propIndex.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HasPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApplication, value.Application); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropHasAllRequested, value.HasAllRequested); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HasPrivilegesResponseConverter))] public sealed partial class HasPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("application")] public IReadOnlyDictionary>> Application { get; init; } - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyDictionary Cluster { get; init; } - [JsonInclude, JsonPropertyName("has_all_requested")] public bool HasAllRequested { get; init; } - [JsonInclude, JsonPropertyName("index")] - [ReadOnlyIndexNameDictionaryConverter(typeof(IReadOnlyDictionary))] public IReadOnlyDictionary> Index { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs index 050f0f7f9b3..8ed86214507 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class HasPrivilegesUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropHasPrivilegeUids = System.Text.Json.JsonEncodedText.Encode("has_privilege_uids"); + + public override HasPrivilegesUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propErrors = default; + LocalJsonProperty> propHasPrivilegeUids = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propHasPrivilegeUids.TryRead(ref reader, options, PropHasPrivilegeUids)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HasPrivilegesUserProfileResponse + { + Errors = propErrors.Value +, + HasPrivilegeUids = propHasPrivilegeUids.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HasPrivilegesUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropHasPrivilegeUids, value.HasPrivilegeUids); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HasPrivilegesUserProfileResponseConverter))] public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResponse { /// @@ -36,7 +83,6 @@ public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResp /// requested privileges. This field is absent if empty. /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Serverless.Security.HasPrivilegesUserProfileErrors? Errors { get; init; } /// @@ -45,6 +91,5 @@ public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResp /// have all the requested privileges. /// /// - [JsonInclude, JsonPropertyName("has_privilege_uids")] public IReadOnlyCollection HasPrivilegeUids { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs index aa223f94def..2d6a8e6feba 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs @@ -18,22 +18,85 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class InvalidateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrorCount = System.Text.Json.JsonEncodedText.Encode("error_count"); + private static readonly System.Text.Json.JsonEncodedText PropErrorDetails = System.Text.Json.JsonEncodedText.Encode("error_details"); + private static readonly System.Text.Json.JsonEncodedText PropInvalidatedApiKeys = System.Text.Json.JsonEncodedText.Encode("invalidated_api_keys"); + private static readonly System.Text.Json.JsonEncodedText PropPreviouslyInvalidatedApiKeys = System.Text.Json.JsonEncodedText.Encode("previously_invalidated_api_keys"); + + public override InvalidateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propErrorCount = default; + LocalJsonProperty?> propErrorDetails = default; + LocalJsonProperty> propInvalidatedApiKeys = default; + LocalJsonProperty> propPreviouslyInvalidatedApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryRead(ref reader, options, PropErrorCount)) + { + continue; + } + + if (propErrorDetails.TryRead(ref reader, options, PropErrorDetails)) + { + continue; + } + + if (propInvalidatedApiKeys.TryRead(ref reader, options, PropInvalidatedApiKeys)) + { + continue; + } + + if (propPreviouslyInvalidatedApiKeys.TryRead(ref reader, options, PropPreviouslyInvalidatedApiKeys)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InvalidateApiKeyResponse + { + ErrorCount = propErrorCount.Value +, + ErrorDetails = propErrorDetails.Value +, + InvalidatedApiKeys = propInvalidatedApiKeys.Value +, + PreviouslyInvalidatedApiKeys = propPreviouslyInvalidatedApiKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InvalidateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrorCount, value.ErrorCount); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails); + writer.WriteProperty(options, PropInvalidatedApiKeys, value.InvalidatedApiKeys); + writer.WriteProperty(options, PropPreviouslyInvalidatedApiKeys, value.PreviouslyInvalidatedApiKeys); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InvalidateApiKeyResponseConverter))] public sealed partial class InvalidateApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error_count")] public int ErrorCount { get; init; } - [JsonInclude, JsonPropertyName("error_details")] public IReadOnlyCollection? ErrorDetails { get; init; } - [JsonInclude, JsonPropertyName("invalidated_api_keys")] public IReadOnlyCollection InvalidatedApiKeys { get; init; } - [JsonInclude, JsonPropertyName("previously_invalidated_api_keys")] public IReadOnlyCollection PreviouslyInvalidatedApiKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateTokenResponse.g.cs index 7d3014db840..3213c411b82 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/InvalidateTokenResponse.g.cs @@ -18,22 +18,85 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class InvalidateTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrorCount = System.Text.Json.JsonEncodedText.Encode("error_count"); + private static readonly System.Text.Json.JsonEncodedText PropErrorDetails = System.Text.Json.JsonEncodedText.Encode("error_details"); + private static readonly System.Text.Json.JsonEncodedText PropInvalidatedTokens = System.Text.Json.JsonEncodedText.Encode("invalidated_tokens"); + private static readonly System.Text.Json.JsonEncodedText PropPreviouslyInvalidatedTokens = System.Text.Json.JsonEncodedText.Encode("previously_invalidated_tokens"); + + public override InvalidateTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propErrorCount = default; + LocalJsonProperty?> propErrorDetails = default; + LocalJsonProperty propInvalidatedTokens = default; + LocalJsonProperty propPreviouslyInvalidatedTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryRead(ref reader, options, PropErrorCount)) + { + continue; + } + + if (propErrorDetails.TryRead(ref reader, options, PropErrorDetails)) + { + continue; + } + + if (propInvalidatedTokens.TryRead(ref reader, options, PropInvalidatedTokens)) + { + continue; + } + + if (propPreviouslyInvalidatedTokens.TryRead(ref reader, options, PropPreviouslyInvalidatedTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InvalidateTokenResponse + { + ErrorCount = propErrorCount.Value +, + ErrorDetails = propErrorDetails.Value +, + InvalidatedTokens = propInvalidatedTokens.Value +, + PreviouslyInvalidatedTokens = propPreviouslyInvalidatedTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InvalidateTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrorCount, value.ErrorCount); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails); + writer.WriteProperty(options, PropInvalidatedTokens, value.InvalidatedTokens); + writer.WriteProperty(options, PropPreviouslyInvalidatedTokens, value.PreviouslyInvalidatedTokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InvalidateTokenResponseConverter))] public sealed partial class InvalidateTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error_count")] public long ErrorCount { get; init; } - [JsonInclude, JsonPropertyName("error_details")] public IReadOnlyCollection? ErrorDetails { get; init; } - [JsonInclude, JsonPropertyName("invalidated_tokens")] public long InvalidatedTokens { get; init; } - [JsonInclude, JsonPropertyName("previously_invalidated_tokens")] public long PreviouslyInvalidatedTokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutPrivilegesRequest.g.cs index 2a4b0e681d5..a21e4f0143a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutPrivilegesRequest.g.cs @@ -47,7 +47,7 @@ public sealed partial class PutPrivilegesRequestParameters : RequestParameters /// Create or update application privileges. /// /// -public sealed partial class PutPrivilegesRequest : PlainRequest, ISelfSerializable +public sealed partial class PutPrivilegesRequest : PlainRequest, ISelfTwoWaySerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutPrivileges; @@ -66,10 +66,15 @@ public sealed partial class PutPrivilegesRequest : PlainRequest Q("refresh"); set => Q("refresh", value); } public Dictionary> Privileges { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Privileges, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Privileges = settings.RequestResponseSerializer.Deserialize>>(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleMappingResponse.g.cs index df37b6dc402..27ea5997fbe 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleMappingResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class PutRoleMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropRoleMapping = System.Text.Json.JsonEncodedText.Encode("role_mapping"); + + public override PutRoleMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCreated = default; + LocalJsonProperty propRoleMapping = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propRoleMapping.TryRead(ref reader, options, PropRoleMapping)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRoleMappingResponse + { + Created = propCreated.Value +, + RoleMapping = propRoleMapping.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRoleMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropRoleMapping, value.RoleMapping); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRoleMappingResponseConverter))] public sealed partial class PutRoleMappingResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool? Created { get; init; } - [JsonInclude, JsonPropertyName("role_mapping")] public Elastic.Clients.Elasticsearch.Serverless.Security.CreatedStatus RoleMapping { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleResponse.g.cs index a08aebbae71..ebb8af81f11 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/PutRoleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class PutRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRole = System.Text.Json.JsonEncodedText.Encode("role"); + + public override PutRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propRole = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRole.TryRead(ref reader, options, PropRole)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRoleResponse + { + Role = propRole.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRole, value.Role); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRoleResponseConverter))] public sealed partial class PutRoleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("role")] public Elastic.Clients.Elasticsearch.Serverless.Security.CreatedStatus Role { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysRequest.g.cs index 4da4639b1b7..ce631517408 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -55,98 +56,86 @@ public sealed partial class QueryApiKeysRequestParameters : RequestParameters public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } } -internal sealed partial class QueryApiKeysRequestConverter : JsonConverter +internal sealed partial class QueryApiKeysRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryApiKeysRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryApiKeysRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new QueryApiKeysRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, QueryApiKeysRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Sort is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryApiKeysRequest { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + Aggregations = propAggregations.Value + , + From = propFrom.Value + , + Query = propQuery.Value + , + SearchAfter = propSearchAfter.Value + , + Size = propSize.Value + , + Sort = propSort.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryApiKeysRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); writer.WriteEndObject(); } } @@ -179,7 +168,6 @@ public QueryApiKeysRequest() /// Determines whether aggregation names are prefixed by their respective types in the response. /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -188,7 +176,6 @@ public QueryApiKeysRequest() /// An API key's actual permission is the intersection of its assigned role descriptors and the owner user's role descriptors. /// /// - [JsonIgnore] public bool? WithLimitedBy { get => Q("with_limited_by"); set => Q("with_limited_by", value); } /// @@ -196,7 +183,6 @@ public QueryApiKeysRequest() /// Determines whether to also retrieve the profile uid, for the API key owner principal, if it exists. /// /// - [JsonIgnore] public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } /// @@ -208,7 +194,6 @@ public QueryApiKeysRequest() /// Additionally, aggregations only run over the same subset of fields that query works with. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -218,7 +203,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -231,7 +215,6 @@ public QueryApiKeysRequest() /// creation, expiration, invalidated, invalidation, username, realm, and metadata. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.Security.ApiKeyQuery? Query { get; set; } /// @@ -239,7 +222,6 @@ public QueryApiKeysRequest() /// Search after definition /// /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -249,7 +231,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -258,8 +239,6 @@ public QueryApiKeysRequest() /// In addition, sort can also be applied to the _doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysResponse.g.cs index 2b1dc469d1f..6fa2cedd5e3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryApiKeysResponse.g.cs @@ -18,14 +18,81 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class QueryApiKeysResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropApiKeys = System.Text.Json.JsonEncodedText.Encode("api_keys"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override QueryApiKeysResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregations = default; + LocalJsonProperty> propApiKeys = default; + LocalJsonProperty propCount = default; + LocalJsonProperty propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propApiKeys.TryRead(ref reader, options, PropApiKeys)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryApiKeysResponse + { + Aggregations = propAggregations.Value +, + ApiKeys = propApiKeys.Value +, + Count = propCount.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryApiKeysResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropApiKeys, value.ApiKeys); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryApiKeysResponseConverter))] public sealed partial class QueryApiKeysResponse : ElasticsearchResponse { /// @@ -33,7 +100,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The aggregations result, if requested. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary? Aggregations { get; init; } /// @@ -41,7 +107,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// A list of API key information. /// /// - [JsonInclude, JsonPropertyName("api_keys")] public IReadOnlyCollection ApiKeys { get; init; } /// @@ -49,7 +114,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The number of API keys returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -57,6 +121,5 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The total number of API keys found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleRequest.g.cs index 7aea332007d..5672a9bd1ab 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,79 @@ public sealed partial class QueryRoleRequestParameters : RequestParameters { } +internal sealed partial class QueryRoleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryRoleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFrom = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRoleRequest + { + From = propFrom.Value +, + Query = propQuery.Value +, + SearchAfter = propSearchAfter.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRoleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteEndObject(); + } +} + /// /// /// Find roles with a query. @@ -42,6 +116,7 @@ public sealed partial class QueryRoleRequestParameters : RequestParameters /// Get roles in a paginated manner. You can optionally filter the results with a query. /// /// +[JsonConverter(typeof(QueryRoleRequestConverter))] public sealed partial class QueryRoleRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryRole; @@ -59,7 +134,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -72,7 +146,6 @@ public sealed partial class QueryRoleRequest : PlainRequestapplications.application, applications.privileges, applications.resources. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.Security.RoleQuery? Query { get; set; } /// @@ -80,7 +153,6 @@ public sealed partial class QueryRoleRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -90,7 +162,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -99,8 +170,6 @@ public sealed partial class QueryRoleRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleResponse.g.cs index 9d55064c136..4e8d7afa634 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryRoleResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class QueryRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override QueryRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propRoles = default; + LocalJsonProperty propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRoleResponse + { + Count = propCount.Value +, + Roles = propRoles.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRoleResponseConverter))] public sealed partial class QueryRoleResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The number of roles returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The list of roles. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection Roles { get; init; } /// @@ -49,6 +104,5 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The total number of roles found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserRequest.g.cs index 3d9242111bb..8c957a0796d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -40,6 +41,79 @@ public sealed partial class QueryUserRequestParameters : RequestParameters public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } } +internal sealed partial class QueryUserRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryUserRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFrom = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryUserRequest + { + From = propFrom.Value + , + Query = propQuery.Value + , + SearchAfter = propSearchAfter.Value + , + Size = propSize.Value + , + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryUserRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteEndObject(); + } +} + /// /// /// Find users with a query. @@ -49,6 +123,7 @@ public sealed partial class QueryUserRequestParameters : RequestParameters /// You can optionally filter the results with a query. /// /// +[JsonConverter(typeof(QueryUserRequestConverter))] public sealed partial class QueryUserRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryUser; @@ -64,7 +139,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonIgnore] public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } /// @@ -74,7 +148,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -86,7 +159,6 @@ public sealed partial class QueryUserRequest : PlainRequestusername, roles, enabled /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.Security.UserQuery? Query { get; set; } /// @@ -94,7 +166,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -104,7 +175,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -113,8 +183,6 @@ public sealed partial class QueryUserRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserResponse.g.cs index adf3180f98f..adf8a468f5f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/QueryUserResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class QueryUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUsers = System.Text.Json.JsonEncodedText.Encode("users"); + + public override QueryUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty propTotal = default; + LocalJsonProperty> propUsers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUsers.TryRead(ref reader, options, PropUsers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryUserResponse + { + Count = propCount.Value +, + Total = propTotal.Value +, + Users = propUsers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUsers, value.Users); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryUserResponseConverter))] public sealed partial class QueryUserResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// The number of users returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// The total number of users found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } /// @@ -49,6 +104,5 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// A list of user information. /// /// - [JsonInclude, JsonPropertyName("users")] public IReadOnlyCollection Users { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlAuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlAuthenticateResponse.g.cs index 9ba0d7b25de..9bc5b9f2f5c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlAuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlAuthenticateResponse.g.cs @@ -18,24 +18,96 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SamlAuthenticateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + private static readonly System.Text.Json.JsonEncodedText PropExpiresIn = System.Text.Json.JsonEncodedText.Encode("expires_in"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override SamlAuthenticateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAccessToken = default; + LocalJsonProperty propExpiresIn = default; + LocalJsonProperty propRealm = default; + LocalJsonProperty propRefreshToken = default; + LocalJsonProperty propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryRead(ref reader, options, PropAccessToken)) + { + continue; + } + + if (propExpiresIn.TryRead(ref reader, options, PropExpiresIn)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRefreshToken.TryRead(ref reader, options, PropRefreshToken)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlAuthenticateResponse + { + AccessToken = propAccessToken.Value +, + ExpiresIn = propExpiresIn.Value +, + Realm = propRealm.Value +, + RefreshToken = propRefreshToken.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlAuthenticateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccessToken, value.AccessToken); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlAuthenticateResponseConverter))] public sealed partial class SamlAuthenticateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("access_token")] public string AccessToken { get; init; } - [JsonInclude, JsonPropertyName("expires_in")] public int ExpiresIn { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("refresh_token")] public string RefreshToken { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlInvalidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlInvalidateResponse.g.cs index 41fa0eb26b9..a984ad74829 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlInvalidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlInvalidateResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SamlInvalidateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInvalidated = System.Text.Json.JsonEncodedText.Encode("invalidated"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlInvalidateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propInvalidated = default; + LocalJsonProperty propRealm = default; + LocalJsonProperty propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInvalidated.TryRead(ref reader, options, PropInvalidated)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlInvalidateResponse + { + Invalidated = propInvalidated.Value +, + Realm = propRealm.Value +, + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlInvalidateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInvalidated, value.Invalidated); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlInvalidateResponseConverter))] public sealed partial class SamlInvalidateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("invalidated")] public int Invalidated { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlLogoutResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlLogoutResponse.g.cs index 0d354b5df3a..24dffca1b7b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlLogoutResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlLogoutResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SamlLogoutResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlLogoutResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlLogoutResponse + { + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlLogoutResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlLogoutResponseConverter))] public sealed partial class SamlLogoutResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs index 892f9c1435b..d1cfa83da54 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SamlPrepareAuthenticationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlPrepareAuthenticationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propId = default; + LocalJsonProperty propRealm = default; + LocalJsonProperty propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlPrepareAuthenticationResponse + { + Id = propId.Value +, + Realm = propRealm.Value +, + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlPrepareAuthenticationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlPrepareAuthenticationResponseConverter))] public sealed partial class SamlPrepareAuthenticationResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs index 05aec4d42a5..4a8158cc2ed 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SamlServiceProviderMetadataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + + public override SamlServiceProviderMetadataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propMetadata = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlServiceProviderMetadataResponse + { + Metadata = propMetadata.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlServiceProviderMetadataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlServiceProviderMetadataResponseConverter))] public sealed partial class SamlServiceProviderMetadataResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("metadata")] public string Metadata { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs index 8aa590fb3b4..f712831c87f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,69 @@ public sealed partial class SuggestUserProfilesRequestParameters : RequestParame { } +internal sealed partial class SuggestUserProfilesRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropHint = System.Text.Json.JsonEncodedText.Encode("hint"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override SuggestUserProfilesRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propData = default; + LocalJsonProperty propHint = default; + LocalJsonProperty propName = default; + LocalJsonProperty propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propHint.TryRead(ref reader, options, PropHint)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SuggestUserProfilesRequest + { + Data = propData.Value +, + Hint = propHint.Value +, + Name = propName.Value +, + Size = propSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestUserProfilesRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropHint, value.Hint); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteEndObject(); + } +} + /// /// /// Suggest a user profile. @@ -42,6 +106,7 @@ public sealed partial class SuggestUserProfilesRequestParameters : RequestParame /// Get suggestions for user profiles that match specified search criteria. /// /// +[JsonConverter(typeof(SuggestUserProfilesRequestConverter))] public sealed partial class SuggestUserProfilesRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySuggestUserProfiles; @@ -60,8 +125,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestdata content. /// /// - [JsonInclude, JsonPropertyName("data")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Data { get; set; } /// @@ -72,7 +135,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestname field query. /// /// - [JsonInclude, JsonPropertyName("hint")] public Elastic.Clients.Elasticsearch.Serverless.Security.Hint? Hint { get; set; } /// @@ -81,7 +143,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestusername, full_name, and email. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; set; } /// @@ -89,7 +150,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("size")] public long? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs index 3ec3181c5a7..7e1c9446b3c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class SuggestUserProfilesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropProfiles = System.Text.Json.JsonEncodedText.Encode("profiles"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override SuggestUserProfilesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propProfiles = default; + LocalJsonProperty propTook = default; + LocalJsonProperty propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propProfiles.TryRead(ref reader, options, PropProfiles)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SuggestUserProfilesResponse + { + Profiles = propProfiles.Value +, + Took = propTook.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestUserProfilesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropProfiles, value.Profiles); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SuggestUserProfilesResponseConverter))] public sealed partial class SuggestUserProfilesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("profiles")] public IReadOnlyCollection Profiles { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public Elastic.Clients.Elasticsearch.Serverless.Security.TotalUserProfiles Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateApiKeyResponse.g.cs index c9a0279b423..bd2e734dbef 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateApiKeyResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class UpdateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpdateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateApiKeyResponse + { + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateApiKeyResponseConverter))] public sealed partial class UpdateApiKeyResponse : ElasticsearchResponse { /// @@ -34,6 +71,5 @@ public sealed partial class UpdateApiKeyResponse : ElasticsearchResponse /// If false, the API key didn’t change because no change was detected. /// /// - [JsonInclude, JsonPropertyName("updated")] public bool Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs index 1c0d0221b89..e7f33398456 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Security; +internal sealed partial class UpdateUserProfileDataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UpdateUserProfileDataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateUserProfileDataResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateUserProfileDataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateUserProfileDataResponseConverter))] public sealed partial class UpdateUserProfileDataResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class UpdateUserProfileDataResponse : ElasticsearchRespons /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs index 55ac4578906..de98a48bc5e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class CleanupRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override CleanupRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CleanupRepositoryResponse + { + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CleanupRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CleanupRepositoryResponseConverter))] public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse /// Statistics for cleanup operations. /// /// - [JsonInclude, JsonPropertyName("results")] public Elastic.Clients.Elasticsearch.Serverless.Snapshot.CleanupRepositoryResults Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs index 270cd3d5615..81cb1413cd5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class CloneSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CloneSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloneSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloneSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloneSnapshotResponseConverter))] public sealed partial class CloneSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class CloneSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file 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 5fbc4fb7562..6b3dfeaf2eb 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 @@ -72,7 +72,7 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter /// If both parameters are specified, only the query parameter is used. /// /// -public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfSerializable +public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfTwoWaySerializable { public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Serverless.Name name) : base(r => r.Required("repository", name)) { @@ -115,13 +115,17 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Serverless.Name nam /// [JsonIgnore] 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) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Repository, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Repository = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs index 8ad697984f4..08c7a854d57 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class CreateRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CreateRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateRepositoryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateRepositoryResponseConverter))] public sealed partial class CreateRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class CreateRepositoryResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs index 5d1a775287e..5fe6b7b5415 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -49,12 +50,106 @@ public sealed partial class CreateSnapshotRequestParameters : RequestParameters public bool? WaitForCompletion { get => Q("wait_for_completion"); set => Q("wait_for_completion", value); } } +internal sealed partial class CreateSnapshotRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropExpandWildcards = System.Text.Json.JsonEncodedText.Encode("expand_wildcards"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureStates = System.Text.Json.JsonEncodedText.Encode("feature_states"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnavailable = System.Text.Json.JsonEncodedText.Encode("ignore_unavailable"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeGlobalState = System.Text.Json.JsonEncodedText.Encode("include_global_state"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropPartial = System.Text.Json.JsonEncodedText.Encode("partial"); + + public override CreateSnapshotRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propExpandWildcards = default; + LocalJsonProperty?> propFeatureStates = default; + LocalJsonProperty propIgnoreUnavailable = default; + LocalJsonProperty propIncludeGlobalState = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty?> propMetadata = default; + LocalJsonProperty propPartial = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExpandWildcards.TryRead(ref reader, options, PropExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>))) + { + continue; + } + + if (propFeatureStates.TryRead(ref reader, options, PropFeatureStates)) + { + continue; + } + + if (propIgnoreUnavailable.TryRead(ref reader, options, PropIgnoreUnavailable)) + { + continue; + } + + if (propIncludeGlobalState.TryRead(ref reader, options, PropIncludeGlobalState)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + if (propPartial.TryRead(ref reader, options, PropPartial)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateSnapshotRequest + { + ExpandWildcards = propExpandWildcards.Value + , + FeatureStates = propFeatureStates.Value + , + IgnoreUnavailable = propIgnoreUnavailable.Value + , + IncludeGlobalState = propIncludeGlobalState.Value + , + Indices = propIndices.Value + , + Metadata = propMetadata.Value + , + Partial = propPartial.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateSnapshotRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>)); + writer.WriteProperty(options, PropFeatureStates, value.FeatureStates); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable); + writer.WriteProperty(options, PropIncludeGlobalState, value.IncludeGlobalState); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteProperty(options, PropPartial, value.Partial); + writer.WriteEndObject(); + } +} + /// /// /// Create a snapshot. /// Take a snapshot of a cluster or of data streams and indices. /// /// +[JsonConverter(typeof(CreateSnapshotRequestConverter))] public sealed partial class CreateSnapshotRequest : PlainRequest { public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repository, Elastic.Clients.Elasticsearch.Serverless.Name snapshot) : base(r => r.Required("repository", repository).Required("snapshot", snapshot)) @@ -75,7 +170,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -84,7 +178,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// If false, the request returns a response when the snapshot initializes. /// /// - [JsonIgnore] public bool? WaitForCompletion { get => Q("wait_for_completion"); set => Q("wait_for_completion", value); } /// @@ -93,8 +186,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// It supports comma-separated values such as open,hidden. /// /// - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } /// @@ -112,7 +203,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// To exclude all feature states, regardless of the include_global_state value, specify an array with only the value none (["none"]). /// /// - [JsonInclude, JsonPropertyName("feature_states")] public ICollection? FeatureStates { get; set; } /// @@ -121,7 +211,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// If false, the request returns an error for any data stream or index that is missing or closed. /// /// - [JsonInclude, JsonPropertyName("ignore_unavailable")] public bool? IgnoreUnavailable { get; set; } /// @@ -131,7 +220,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// It also includes data stored in system indices, such as Watches and task records (configurable via feature_states). /// /// - [JsonInclude, JsonPropertyName("include_global_state")] public bool? IncludeGlobalState { get; set; } /// @@ -146,7 +234,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// Use feature_states instead. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } /// @@ -156,7 +243,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// This information is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("metadata")] public IDictionary? Metadata { get; set; } /// @@ -169,7 +255,6 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Serverless.Name repos /// If false, the entire restore operation will fail if one or more indices included in the snapshot do not have all primary shards available. /// /// - [JsonInclude, JsonPropertyName("partial")] public bool? Partial { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs index 5a29b97af9c..236ead1ee46 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class CreateSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccepted = System.Text.Json.JsonEncodedText.Encode("accepted"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override CreateSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAccepted = default; + LocalJsonProperty propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryRead(ref reader, options, PropAccepted)) + { + continue; + } + + if (propSnapshot.TryRead(ref reader, options, PropSnapshot)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateSnapshotResponse + { + Accepted = propAccepted.Value +, + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccepted, value.Accepted); + writer.WriteProperty(options, PropSnapshot, value.Snapshot); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateSnapshotResponseConverter))] public sealed partial class CreateSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class CreateSnapshotResponse : ElasticsearchResponse /// Equals true if the snapshot was accepted. Present when the request had wait_for_completion set to false /// /// - [JsonInclude, JsonPropertyName("accepted")] public bool? Accepted { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class CreateSnapshotResponse : ElasticsearchResponse /// Snapshot information. Present when the request had wait_for_completion set to true /// /// - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.Serverless.Snapshot.SnapshotInfo? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs index b9feee61eab..63ded85d288 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class DeleteRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRepositoryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRepositoryResponseConverter))] public sealed partial class DeleteRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteRepositoryResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs index 1657e82dd35..14061c3c699 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class DeleteSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSnapshotResponseConverter))] public sealed partial class DeleteSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs index c60a2655c2c..fd9bdf87c3f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class GetSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNext = System.Text.Json.JsonEncodedText.Encode("next"); + private static readonly System.Text.Json.JsonEncodedText PropRemaining = System.Text.Json.JsonEncodedText.Encode("remaining"); + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshots = System.Text.Json.JsonEncodedText.Encode("snapshots"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override GetSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propNext = default; + LocalJsonProperty propRemaining = default; + LocalJsonProperty?> propResponses = default; + LocalJsonProperty?> propSnapshots = default; + LocalJsonProperty propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNext.TryRead(ref reader, options, PropNext)) + { + continue; + } + + if (propRemaining.TryRead(ref reader, options, PropRemaining)) + { + continue; + } + + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propSnapshots.TryRead(ref reader, options, PropSnapshots)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSnapshotResponse + { + Next = propNext.Value +, + Remaining = propRemaining.Value +, + Responses = propResponses.Value +, + Snapshots = propSnapshots.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNext, value.Next); + writer.WriteProperty(options, PropRemaining, value.Remaining); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropSnapshots, value.Snapshots); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSnapshotResponseConverter))] public sealed partial class GetSnapshotResponse : ElasticsearchResponse { /// @@ -34,7 +111,6 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// It can be used as the after query parameter to fetch additional results. /// /// - [JsonInclude, JsonPropertyName("next")] public string? Next { get; init; } /// @@ -42,11 +118,8 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// The number of remaining snapshots that were not returned due to size limits and that can be fetched by additional requests using the next field value. /// /// - [JsonInclude, JsonPropertyName("remaining")] public int Remaining { get; init; } - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection? Responses { get; init; } - [JsonInclude, JsonPropertyName("snapshots")] public IReadOnlyCollection? Snapshots { get; init; } /// @@ -54,6 +127,5 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// The total number of snapshots that match the request when ignoring the size limit or after query parameter. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/RestoreResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/RestoreResponse.g.cs index 0ee5b1548b6..9c4deff841f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/RestoreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/RestoreResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class RestoreResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccepted = System.Text.Json.JsonEncodedText.Encode("accepted"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override RestoreResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAccepted = default; + LocalJsonProperty propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryRead(ref reader, options, PropAccepted)) + { + continue; + } + + if (propSnapshot.TryRead(ref reader, options, PropSnapshot)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RestoreResponse + { + Accepted = propAccepted.Value +, + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RestoreResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccepted, value.Accepted); + writer.WriteProperty(options, PropSnapshot, value.Snapshot); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RestoreResponseConverter))] public sealed partial class RestoreResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("accepted")] public bool? Accepted { get; init; } - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.Serverless.Snapshot.SnapshotRestore? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs index ce5388ec913..068fe27f475 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class SnapshotStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshots = System.Text.Json.JsonEncodedText.Encode("snapshots"); + + public override SnapshotStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshots.TryRead(ref reader, options, PropSnapshots)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SnapshotStatusResponse + { + Snapshots = propSnapshots.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshots, value.Snapshots); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SnapshotStatusResponseConverter))] public sealed partial class SnapshotStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshots")] public IReadOnlyCollection Snapshots { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs index dd525ba1d2f..73229b5cd66 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Snapshot; +internal sealed partial class VerifyRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override VerifyRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VerifyRepositoryResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, VerifyRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VerifyRepositoryResponseConverter))] public sealed partial class VerifyRepositoryResponse : ElasticsearchResponse { /// @@ -34,6 +71,5 @@ public sealed partial class VerifyRepositoryResponse : ElasticsearchResponse /// The key is the ID of the node. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs index c55e6564aa6..e0b943bbff9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class DeleteLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLifecycleResponseConverter))] public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs index c3b46581b3c..fb465c2d444 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class ExecuteLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshotName = System.Text.Json.JsonEncodedText.Encode("snapshot_name"); + + public override ExecuteLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propSnapshotName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshotName.TryRead(ref reader, options, PropSnapshotName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecuteLifecycleResponse + { + SnapshotName = propSnapshotName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecuteLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshotName, value.SnapshotName); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecuteLifecycleResponseConverter))] public sealed partial class ExecuteLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshot_name")] public string SnapshotName { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs index df9da9e895a..03a3b299019 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class ExecuteRetentionResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ExecuteRetentionResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecuteRetentionResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecuteRetentionResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecuteRetentionResponseConverter))] public sealed partial class ExecuteRetentionResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ExecuteRetentionResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs index 65874614e4f..7a0d4fd1af2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class GetSlmStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOperationMode = System.Text.Json.JsonEncodedText.Encode("operation_mode"); + + public override GetSlmStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propOperationMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOperationMode.TryRead(ref reader, options, PropOperationMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSlmStatusResponse + { + OperationMode = propOperationMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSlmStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOperationMode, value.OperationMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSlmStatusResponseConverter))] public sealed partial class GetSlmStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("operation_mode")] public Elastic.Clients.Elasticsearch.Serverless.LifecycleOperationMode OperationMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs index 3306a7ae841..365ecb813ad 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs @@ -18,34 +18,151 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class GetStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPolicyStats = System.Text.Json.JsonEncodedText.Encode("policy_stats"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionDeletionTime = System.Text.Json.JsonEncodedText.Encode("retention_deletion_time"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionDeletionTimeMillis = System.Text.Json.JsonEncodedText.Encode("retention_deletion_time_millis"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionFailed = System.Text.Json.JsonEncodedText.Encode("retention_failed"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionRuns = System.Text.Json.JsonEncodedText.Encode("retention_runs"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionTimedOut = System.Text.Json.JsonEncodedText.Encode("retention_timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotDeletionFailures = System.Text.Json.JsonEncodedText.Encode("total_snapshot_deletion_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsDeleted = System.Text.Json.JsonEncodedText.Encode("total_snapshots_deleted"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsFailed = System.Text.Json.JsonEncodedText.Encode("total_snapshots_failed"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsTaken = System.Text.Json.JsonEncodedText.Encode("total_snapshots_taken"); + + public override GetStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propPolicyStats = default; + LocalJsonProperty propRetentionDeletionTime = default; + LocalJsonProperty propRetentionDeletionTimeMillis = default; + LocalJsonProperty propRetentionFailed = default; + LocalJsonProperty propRetentionRuns = default; + LocalJsonProperty propRetentionTimedOut = default; + LocalJsonProperty propTotalSnapshotDeletionFailures = default; + LocalJsonProperty propTotalSnapshotsDeleted = default; + LocalJsonProperty propTotalSnapshotsFailed = default; + LocalJsonProperty propTotalSnapshotsTaken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicyStats.TryRead(ref reader, options, PropPolicyStats)) + { + continue; + } + + if (propRetentionDeletionTime.TryRead(ref reader, options, PropRetentionDeletionTime)) + { + continue; + } + + if (propRetentionDeletionTimeMillis.TryRead(ref reader, options, PropRetentionDeletionTimeMillis)) + { + continue; + } + + if (propRetentionFailed.TryRead(ref reader, options, PropRetentionFailed)) + { + continue; + } + + if (propRetentionRuns.TryRead(ref reader, options, PropRetentionRuns)) + { + continue; + } + + if (propRetentionTimedOut.TryRead(ref reader, options, PropRetentionTimedOut)) + { + continue; + } + + if (propTotalSnapshotDeletionFailures.TryRead(ref reader, options, PropTotalSnapshotDeletionFailures)) + { + continue; + } + + if (propTotalSnapshotsDeleted.TryRead(ref reader, options, PropTotalSnapshotsDeleted)) + { + continue; + } + + if (propTotalSnapshotsFailed.TryRead(ref reader, options, PropTotalSnapshotsFailed)) + { + continue; + } + + if (propTotalSnapshotsTaken.TryRead(ref reader, options, PropTotalSnapshotsTaken)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetStatsResponse + { + PolicyStats = propPolicyStats.Value +, + RetentionDeletionTime = propRetentionDeletionTime.Value +, + RetentionDeletionTimeMillis = propRetentionDeletionTimeMillis.Value +, + RetentionFailed = propRetentionFailed.Value +, + RetentionRuns = propRetentionRuns.Value +, + RetentionTimedOut = propRetentionTimedOut.Value +, + TotalSnapshotDeletionFailures = propTotalSnapshotDeletionFailures.Value +, + TotalSnapshotsDeleted = propTotalSnapshotsDeleted.Value +, + TotalSnapshotsFailed = propTotalSnapshotsFailed.Value +, + TotalSnapshotsTaken = propTotalSnapshotsTaken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPolicyStats, value.PolicyStats); + writer.WriteProperty(options, PropRetentionDeletionTime, value.RetentionDeletionTime); + writer.WriteProperty(options, PropRetentionDeletionTimeMillis, value.RetentionDeletionTimeMillis); + writer.WriteProperty(options, PropRetentionFailed, value.RetentionFailed); + writer.WriteProperty(options, PropRetentionRuns, value.RetentionRuns); + writer.WriteProperty(options, PropRetentionTimedOut, value.RetentionTimedOut); + writer.WriteProperty(options, PropTotalSnapshotDeletionFailures, value.TotalSnapshotDeletionFailures); + writer.WriteProperty(options, PropTotalSnapshotsDeleted, value.TotalSnapshotsDeleted); + writer.WriteProperty(options, PropTotalSnapshotsFailed, value.TotalSnapshotsFailed); + writer.WriteProperty(options, PropTotalSnapshotsTaken, value.TotalSnapshotsTaken); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetStatsResponseConverter))] public sealed partial class GetStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("policy_stats")] public IReadOnlyCollection PolicyStats { get; init; } - [JsonInclude, JsonPropertyName("retention_deletion_time")] public Elastic.Clients.Elasticsearch.Serverless.Duration RetentionDeletionTime { get; init; } - [JsonInclude, JsonPropertyName("retention_deletion_time_millis")] public long RetentionDeletionTimeMillis { get; init; } - [JsonInclude, JsonPropertyName("retention_failed")] public long RetentionFailed { get; init; } - [JsonInclude, JsonPropertyName("retention_runs")] public long RetentionRuns { get; init; } - [JsonInclude, JsonPropertyName("retention_timed_out")] public long RetentionTimedOut { get; init; } - [JsonInclude, JsonPropertyName("total_snapshot_deletion_failures")] public long TotalSnapshotDeletionFailures { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_deleted")] public long TotalSnapshotsDeleted { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_failed")] public long TotalSnapshotsFailed { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_taken")] public long TotalSnapshotsTaken { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs index 81e78167d5f..26b373f8916 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class PutLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutLifecycleResponseConverter))] public sealed partial class PutLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs index 3c808d5388b..330844a8095 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class StartSlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartSlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartSlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartSlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartSlmResponseConverter))] public sealed partial class StartSlmResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class StartSlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs index 158747d810b..091dc6f5fac 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.SnapshotLifecycleManagement; +internal sealed partial class StopSlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopSlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopSlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopSlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopSlmResponseConverter))] public sealed partial class StopSlmResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class StopSlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/ClearCursorResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/ClearCursorResponse.g.cs index 821827b04e5..5ce62c01cab 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/ClearCursorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/ClearCursorResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class ClearCursorResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClearCursorResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCursorResponse + { + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCursorResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCursorResponseConverter))] public sealed partial class ClearCursorResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/DeleteAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/DeleteAsyncResponse.g.cs index 09cfb3fee42..f3c073810f6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/DeleteAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/DeleteAsyncResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class DeleteAsyncResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAsyncResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAsyncResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAsyncResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncResponseConverter))] public sealed partial class DeleteAsyncResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteAsyncResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncResponse.g.cs index b2f81b3bb98..4b99049e15d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class GetAsyncResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropColumns = System.Text.Json.JsonEncodedText.Encode("columns"); + private static readonly System.Text.Json.JsonEncodedText PropCursor = System.Text.Json.JsonEncodedText.Encode("cursor"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + + public override GetAsyncResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propColumns = default; + LocalJsonProperty propCursor = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryRead(ref reader, options, PropColumns)) + { + continue; + } + + if (propCursor.TryRead(ref reader, options, PropCursor)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncResponse + { + Columns = propColumns.Value +, + Cursor = propCursor.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropColumns, value.Columns); + writer.WriteProperty(options, PropCursor, value.Cursor); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncResponseConverter))] public sealed partial class GetAsyncResponse : ElasticsearchResponse { /// @@ -33,7 +110,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// Column headings for the search results. Each object is a column. /// /// - [JsonInclude, JsonPropertyName("columns")] public IReadOnlyCollection? Columns { get; init; } /// @@ -42,7 +118,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// TXT responses, this value is returned in the Cursor HTTP header. /// /// - [JsonInclude, JsonPropertyName("cursor")] public string? Cursor { get; init; } /// @@ -52,7 +127,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -64,7 +138,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// For CSV, TSV, and TXT responses, this value is returned in the Async-partial HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -75,6 +148,5 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs index 7e4c8941777..678dee31c04 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs @@ -18,14 +18,101 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class GetAsyncStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetAsyncStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCompletionStatus = default; + LocalJsonProperty propExpirationTimeInMillis = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + LocalJsonProperty propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncStatusResponse + { + CompletionStatus = propCompletionStatus.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncStatusResponseConverter))] public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse { /// @@ -33,7 +120,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// HTTP status code for the search. The API only returns this property for completed searches. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -42,7 +128,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// the search and its results, even if the search is still running. /// /// - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } /// @@ -50,7 +135,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -61,7 +145,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// timeout. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -69,7 +152,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// If true, the search is still running. If false, the search has finished. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -78,6 +160,5 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// The API only returns this property for running searches. /// /// - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/QueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/QueryResponse.g.cs index 3b1a52167ce..15e7cdd9418 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/QueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/QueryResponse.g.cs @@ -18,14 +18,91 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class QueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropColumns = System.Text.Json.JsonEncodedText.Encode("columns"); + private static readonly System.Text.Json.JsonEncodedText PropCursor = System.Text.Json.JsonEncodedText.Encode("cursor"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + + public override QueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propColumns = default; + LocalJsonProperty propCursor = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIsPartial = default; + LocalJsonProperty propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryRead(ref reader, options, PropColumns)) + { + continue; + } + + if (propCursor.TryRead(ref reader, options, PropCursor)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryResponse + { + Columns = propColumns.Value +, + Cursor = propCursor.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropColumns, value.Columns); + writer.WriteProperty(options, PropCursor, value.Cursor); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryResponseConverter))] public sealed partial class QueryResponse : ElasticsearchResponse { /// @@ -33,7 +110,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// Column headings for the search results. Each object is a column. /// /// - [JsonInclude, JsonPropertyName("columns")] public IReadOnlyCollection? Columns { get; init; } /// @@ -42,7 +118,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// TXT responses, this value is returned in the Cursor HTTP header. /// /// - [JsonInclude, JsonPropertyName("cursor")] public string? Cursor { get; init; } /// @@ -52,7 +127,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -64,7 +138,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// For CSV, TSV, and TXT responses, this value is returned in the Async-partial HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -75,6 +148,5 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/TranslateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/TranslateResponse.g.cs index 99fbe12d829..bb2943db053 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/TranslateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Sql/TranslateResponse.g.cs @@ -18,27 +18,107 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Sql; +internal sealed partial class TranslateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override TranslateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TranslateResponse + { + Aggregations = propAggregations.Value +, + Fields = propFields.Value +, + Query = propQuery.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TranslateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TranslateResponseConverter))] public sealed partial class TranslateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyCollection? Fields { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; init; } - [JsonInclude, JsonPropertyName("size")] public long? Size { get; init; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public IReadOnlyCollection? Sort { get; init; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs index 479bdd5aaa4..01452b5eeb5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class DeleteSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSynonymResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymResponseConverter))] public sealed partial class DeleteSynonymResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteSynonymResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs index 73974df9ed9..8bbb903060f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class DeleteSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override DeleteSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propReloadAnalyzersDetails = default; + LocalJsonProperty propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSynonymRuleResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymRuleResponseConverter))] public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +81,6 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +88,5 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymResponse.g.cs index b9a0e5a1d26..b070575ab30 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class GetSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropSynonymsSet = System.Text.Json.JsonEncodedText.Encode("synonyms_set"); + + public override GetSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propSynonymsSet.TryRead(ref reader, options, PropSynonymsSet)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymResponse + { + Count = propCount.Value +, + SynonymsSet = propSynonymsSet.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropSynonymsSet, value.SynonymsSet); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymResponseConverter))] public sealed partial class GetSynonymResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } - [JsonInclude, JsonPropertyName("synonyms_set")] public IReadOnlyCollection SynonymsSet { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs index ddf0532449c..5056ea5c257 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class GetSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropSynonyms = System.Text.Json.JsonEncodedText.Encode("synonyms"); + + public override GetSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propId = default; + LocalJsonProperty propSynonyms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propSynonyms.TryRead(ref reader, options, PropSynonyms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymRuleResponse + { + Id = propId.Value +, + Synonyms = propSynonyms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropSynonyms, value.Synonyms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymRuleResponseConverter))] public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse { /// @@ -33,7 +80,6 @@ public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse /// Synonym Rule identifier /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -41,6 +87,5 @@ public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse /// Synonyms, in Solr format, that conform the synonym rule. See https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-graph-tokenfilter.html#_solr_synonyms_2 /// /// - [JsonInclude, JsonPropertyName("synonyms")] public string Synonyms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs index d995d7a68a9..6f437f7d0d6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class GetSynonymsSetsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override GetSynonymsSetsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymsSetsResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymsSetsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymsSetsResponseConverter))] public sealed partial class GetSynonymsSetsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } - [JsonInclude, JsonPropertyName("results")] public IReadOnlyCollection Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRequest.g.cs index 917cc4d52a7..fb695bc6c4b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -34,6 +35,39 @@ public sealed partial class PutSynonymRequestParameters : RequestParameters { } +internal sealed partial class PutSynonymRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSynonymsSet = System.Text.Json.JsonEncodedText.Encode("synonyms_set"); + + public override PutSynonymRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSynonymsSet.TryRead(ref reader, options, PropSynonymsSet, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Synonyms.SynonymRule>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymRequest + { + SynonymsSet = propSynonymsSet.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSynonymsSet, value.SynonymsSet, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Synonyms.SynonymRule>)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a synonym set. @@ -41,6 +75,7 @@ public sealed partial class PutSynonymRequestParameters : RequestParameters /// If you need to manage more synonym rules, you can create multiple synonym sets. /// /// +[JsonConverter(typeof(PutSynonymRequestConverter))] public sealed partial class PutSynonymRequest : PlainRequest { public PutSynonymRequest(Elastic.Clients.Elasticsearch.Serverless.Id id) : base(r => r.Required("id", id)) @@ -60,8 +95,6 @@ public PutSynonymRequest(Elastic.Clients.Elasticsearch.Serverless.Id id) : base( /// The synonym set information to update /// /// - [JsonInclude, JsonPropertyName("synonyms_set")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Synonyms.SynonymRule))] public ICollection SynonymsSet { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymResponse.g.cs index 7d199169ef8..1ea5f244476 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class PutSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propReloadAnalyzersDetails = default; + LocalJsonProperty propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymResponseConverter))] public sealed partial class PutSynonymResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs index 242f0cd0cde..1d251b26dc5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs @@ -18,14 +18,61 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Synonyms; +internal sealed partial class PutSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propReloadAnalyzersDetails = default; + LocalJsonProperty propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymRuleResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymRuleResponseConverter))] public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +81,6 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +88,5 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsRequest.g.cs index 7854f379409..971ac783c59 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -112,6 +113,76 @@ public sealed partial class TermVectorsRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } } +internal sealed partial class TermVectorsRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropPerFieldAnalyzer = System.Text.Json.JsonEncodedText.Encode("per_field_analyzer"); + + public override TermVectorsRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDoc = default; + LocalJsonProperty propFilter = default; + LocalJsonProperty?> propPerFieldAnalyzer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc, typeof(SourceMarker))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propPerFieldAnalyzer.TryRead(ref reader, options, PropPerFieldAnalyzer)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermVectorsRequest + { + Doc = propDoc.Value + , + Filter = propFilter.Value + , + PerFieldAnalyzer = propPerFieldAnalyzer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorsRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc, typeof(SourceMarker)); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropPerFieldAnalyzer, value.PerFieldAnalyzer); + writer.WriteEndObject(); + } +} + +internal sealed partial class TermVectorsRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(TermVectorsRequest<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(TermVectorsRequestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Get term vector information. @@ -120,6 +191,7 @@ public sealed partial class TermVectorsRequestParameters : RequestParameters /// Get information and statistics about terms in the fields of a particular document. /// /// +[JsonConverter(typeof(TermVectorsRequestConverterFactory))] public sealed partial class TermVectorsRequest : PlainRequest { public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id? id) : base(r => r.Required("index", index).Optional("id", id)) @@ -144,7 +216,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Used as the default list unless a specific field list is provided in the completion_fields or fielddata_fields parameters. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get => Q("fields"); set => Q("fields", value); } /// @@ -152,7 +223,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the response includes the document count, sum of document frequencies, and sum of total term frequencies. /// /// - [JsonIgnore] public bool? FieldStatistics { get => Q("field_statistics"); set => Q("field_statistics", value); } /// @@ -160,7 +230,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the response includes term offsets. /// /// - [JsonIgnore] public bool? Offsets { get => Q("offsets"); set => Q("offsets", value); } /// @@ -168,7 +237,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the response includes term payloads. /// /// - [JsonIgnore] public bool? Payloads { get => Q("payloads"); set => Q("payloads", value); } /// @@ -176,7 +244,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the response includes term positions. /// /// - [JsonIgnore] public bool? Positions { get => Q("positions"); set => Q("positions", value); } /// @@ -185,7 +252,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Random by default. /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -193,7 +259,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the request is real-time as opposed to near-real-time. /// /// - [JsonIgnore] public bool? Realtime { get => Q("realtime"); set => Q("realtime", value); } /// @@ -201,7 +266,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -209,7 +273,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, the response includes term frequency and document frequency. /// /// - [JsonIgnore] public bool? TermStatistics { get => Q("term_statistics"); set => Q("term_statistics", value); } /// @@ -217,7 +280,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// If true, returns the document version as part of a hit. /// /// - [JsonIgnore] public long? Version { get => Q("version"); set => Q("version", value); } /// @@ -225,7 +287,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Specific version type. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } /// @@ -233,8 +294,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// An artificial document (a document not present in the index) for which you want to retrieve term vectors. /// /// - [JsonInclude, JsonPropertyName("doc")] - [SourceConverter] public TDocument? Doc { get; set; } /// @@ -242,7 +301,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Serverless.Core.TermVectors.Filter? Filter { get; set; } /// @@ -250,7 +308,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName ind /// Overrides the default per-field analyzer. /// /// - [JsonInclude, JsonPropertyName("per_field_analyzer")] public IDictionary? PerFieldAnalyzer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsResponse.g.cs index f2c69d342cf..756bc61a5ed 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermVectorsResponse.g.cs @@ -18,27 +18,107 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class TermVectorsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropTermVectors = System.Text.Json.JsonEncodedText.Encode("term_vectors"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override TermVectorsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFound = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propTermVectors = default; + LocalJsonProperty propTook = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propTermVectors.TryRead(ref reader, options, PropTermVectors)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermVectorsResponse + { + Found = propFound.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + TermVectors = propTermVectors.Value +, + Took = propTook.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropTermVectors, value.TermVectors); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermVectorsResponseConverter))] public sealed partial class TermVectorsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("term_vectors")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.TermVectors.TermVector))] public IReadOnlyDictionary? TermVectors { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermsEnumResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermsEnumResponse.g.cs index 622d36f7f49..7d9c20d6a44 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermsEnumResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TermsEnumResponse.g.cs @@ -18,20 +18,74 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class TermsEnumResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropComplete = System.Text.Json.JsonEncodedText.Encode("complete"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override TermsEnumResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propComplete = default; + LocalJsonProperty propShards = default; + LocalJsonProperty> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComplete.TryRead(ref reader, options, PropComplete)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsEnumResponse + { + Complete = propComplete.Value +, + Shards = propShards.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsEnumResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropComplete, value.Complete); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTerms, value.Terms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsEnumResponseConverter))] public sealed partial class TermsEnumResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("complete")] public bool Complete { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("terms")] public IReadOnlyCollection Terms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs index 6eafe234525..6d904c196cb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TextStructure; +internal sealed partial class TestGrokPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMatches = System.Text.Json.JsonEncodedText.Encode("matches"); + + public override TestGrokPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propMatches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatches.TryRead(ref reader, options, PropMatches)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TestGrokPatternResponse + { + Matches = propMatches.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TestGrokPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMatches, value.Matches); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TestGrokPatternResponseConverter))] public sealed partial class TestGrokPatternResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("matches")] public IReadOnlyCollection Matches { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs index b39ea167e98..dcef9580976 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class DeleteTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTransformResponseConverter))] public sealed partial class DeleteTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class DeleteTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformResponse.g.cs index 44e4b3afaa7..129510ee75d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class GetTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTransforms = System.Text.Json.JsonEncodedText.Encode("transforms"); + + public override GetTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTransforms.TryRead(ref reader, options, PropTransforms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTransformResponse + { + Count = propCount.Value +, + Transforms = propTransforms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTransforms, value.Transforms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTransformResponseConverter))] public sealed partial class GetTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("transforms")] public IReadOnlyCollection Transforms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs index ad4f91559ef..886e5cd5657 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs @@ -18,18 +18,63 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class GetTransformStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTransforms = System.Text.Json.JsonEncodedText.Encode("transforms"); + + public override GetTransformStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCount = default; + LocalJsonProperty> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTransforms.TryRead(ref reader, options, PropTransforms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTransformStatsResponse + { + Count = propCount.Value +, + Transforms = propTransforms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTransformStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTransforms, value.Transforms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTransformStatsResponseConverter))] public sealed partial class GetTransformStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("transforms")] public IReadOnlyCollection Transforms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs index 83b1131f2bf..1bf5da7859e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs @@ -18,18 +18,80 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class PreviewTransformResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropGeneratedDestIndex = System.Text.Json.JsonEncodedText.Encode("generated_dest_index"); + private static readonly System.Text.Json.JsonEncodedText PropPreview = System.Text.Json.JsonEncodedText.Encode("preview"); + + public override PreviewTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propGeneratedDestIndex = default; + LocalJsonProperty> propPreview = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propGeneratedDestIndex.TryRead(ref reader, options, PropGeneratedDestIndex)) + { + continue; + } + + if (propPreview.TryRead(ref reader, options, PropPreview)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PreviewTransformResponse + { + GeneratedDestIndex = propGeneratedDestIndex.Value +, + Preview = propPreview.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PreviewTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropGeneratedDestIndex, value.GeneratedDestIndex); + writer.WriteProperty(options, PropPreview, value.Preview); + writer.WriteEndObject(); + } +} + +internal sealed partial class PreviewTransformResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(PreviewTransformResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(PreviewTransformResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(PreviewTransformResponseConverterFactory))] public sealed partial class PreviewTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("generated_dest_index")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexState GeneratedDestIndex { get; init; } - [JsonInclude, JsonPropertyName("preview")] public IReadOnlyCollection Preview { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PutTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PutTransformResponse.g.cs index 37567c05c87..eaf411d65d3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PutTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/PutTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class PutTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTransformResponseConverter))] public sealed partial class PutTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class PutTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs index d97e012a67e..cfdd2d4687f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class ResetTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResetTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetTransformResponseConverter))] public sealed partial class ResetTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ResetTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs index c9a9273b214..175acdd0c9b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class ScheduleNowTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ScheduleNowTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScheduleNowTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScheduleNowTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ScheduleNowTransformResponseConverter))] public sealed partial class ScheduleNowTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class ScheduleNowTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StartTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StartTransformResponse.g.cs index 595a38b4095..784445cfea7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StartTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StartTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class StartTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTransformResponseConverter))] public sealed partial class StartTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class StartTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StopTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StopTransformResponse.g.cs index 985c2bcd51a..122bc85df62 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StopTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/StopTransformResponse.g.cs @@ -18,14 +18,51 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class StopTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTransformResponseConverter))] public sealed partial class StopTransformResponse : ElasticsearchResponse { /// @@ -33,6 +70,5 @@ public sealed partial class StopTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs index 3d804e206b9..17e8a9de046 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs @@ -18,42 +18,195 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class UpdateTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropLatest = System.Text.Json.JsonEncodedText.Encode("latest"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropPivot = System.Text.Json.JsonEncodedText.Encode("pivot"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionPolicy = System.Text.Json.JsonEncodedText.Encode("retention_policy"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropSync = System.Text.Json.JsonEncodedText.Encode("sync"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override UpdateTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propCreateTime = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propDest = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty propId = default; + LocalJsonProperty propLatest = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propPivot = default; + LocalJsonProperty propRetentionPolicy = default; + LocalJsonProperty propSettings = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propSync = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propLatest.TryRead(ref reader, options, PropLatest)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPivot.TryRead(ref reader, options, PropPivot)) + { + continue; + } + + if (propRetentionPolicy.TryRead(ref reader, options, PropRetentionPolicy)) + { + continue; + } + + if (propSettings.TryRead(ref reader, options, PropSettings)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propSync.TryRead(ref reader, options, PropSync)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateTransformResponse + { + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Frequency = propFrequency.Value +, + Id = propId.Value +, + Latest = propLatest.Value +, + Meta = propMeta.Value +, + Pivot = propPivot.Value +, + RetentionPolicy = propRetentionPolicy.Value +, + Settings = propSettings.Value +, + Source = propSource.Value +, + Sync = propSync.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropLatest, value.Latest); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPivot, value.Pivot); + writer.WriteProperty(options, PropRetentionPolicy, value.RetentionPolicy); + writer.WriteProperty(options, PropSettings, value.Settings); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropSync, value.Sync); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateTransformResponseConverter))] public sealed partial class UpdateTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TransformAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.Serverless.Core.Reindex.Destination Dest { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("latest")] public Elastic.Clients.Elasticsearch.Serverless.TransformManagement.Latest? Latest { get; init; } - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } - [JsonInclude, JsonPropertyName("pivot")] public Elastic.Clients.Elasticsearch.Serverless.TransformManagement.Pivot? Pivot { get; init; } - [JsonInclude, JsonPropertyName("retention_policy")] public Elastic.Clients.Elasticsearch.Serverless.TransformManagement.RetentionPolicy? RetentionPolicy { get; init; } - [JsonInclude, JsonPropertyName("settings")] public Elastic.Clients.Elasticsearch.Serverless.TransformManagement.Settings Settings { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Reindex.Source Source { get; init; } - [JsonInclude, JsonPropertyName("sync")] public Elastic.Clients.Elasticsearch.Serverless.TransformManagement.Sync? Sync { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs index 0d286e7ad75..06eae291da0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs @@ -18,14 +18,71 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.TransformManagement; +internal sealed partial class UpgradeTransformsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNeedsUpdate = System.Text.Json.JsonEncodedText.Encode("needs_update"); + private static readonly System.Text.Json.JsonEncodedText PropNoAction = System.Text.Json.JsonEncodedText.Encode("no_action"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpgradeTransformsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propNeedsUpdate = default; + LocalJsonProperty propNoAction = default; + LocalJsonProperty propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNeedsUpdate.TryRead(ref reader, options, PropNeedsUpdate)) + { + continue; + } + + if (propNoAction.TryRead(ref reader, options, PropNoAction)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpgradeTransformsResponse + { + NeedsUpdate = propNeedsUpdate.Value +, + NoAction = propNoAction.Value +, + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpgradeTransformsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNeedsUpdate, value.NeedsUpdate); + writer.WriteProperty(options, PropNoAction, value.NoAction); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeTransformsResponseConverter))] public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse { /// @@ -33,7 +90,6 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that need to be upgraded. /// /// - [JsonInclude, JsonPropertyName("needs_update")] public int NeedsUpdate { get; init; } /// @@ -41,7 +97,6 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that don’t require upgrading. /// /// - [JsonInclude, JsonPropertyName("no_action")] public int NoAction { get; init; } /// @@ -49,6 +104,5 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that have been upgraded. /// /// - [JsonInclude, JsonPropertyName("updated")] public int Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryResponse.g.cs index e5772ccd603..51e790dacba 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryResponse.g.cs @@ -18,46 +18,217 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class UpdateByQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntil = System.Text.Json.JsonEncodedText.Encode("throttled_until"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override UpdateByQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBatches = default; + LocalJsonProperty propDeleted = default; + LocalJsonProperty?> propFailures = default; + LocalJsonProperty propNoops = default; + LocalJsonProperty propRequestsPerSecond = default; + LocalJsonProperty propRetries = default; + LocalJsonProperty propTask = default; + LocalJsonProperty propThrottled = default; + LocalJsonProperty propThrottledMillis = default; + LocalJsonProperty propThrottledUntil = default; + LocalJsonProperty propThrottledUntilMillis = default; + LocalJsonProperty propTimedOut = default; + LocalJsonProperty propTook = default; + LocalJsonProperty propTotal = default; + LocalJsonProperty propUpdated = default; + LocalJsonProperty propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottled.TryRead(ref reader, options, PropThrottled)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntil.TryRead(ref reader, options, PropThrottledUntil)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateByQueryResponse + { + Batches = propBatches.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + Task = propTask.Value +, + Throttled = propThrottled.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntil = propThrottledUntil.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + Updated = propUpdated.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateByQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottled, value.Throttled); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateByQueryResponseConverter))] public sealed partial class UpdateByQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Serverless.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.Serverless.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.Serverless.Duration? ThrottledUntil { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("updated")] public long? Updated { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs index 14c964850d0..2746c2d7499 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs @@ -18,16 +18,52 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class UpdateByQueryRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override UpdateByQueryRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateByQueryRethrottleResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateByQueryRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateByQueryRethrottleResponseConverter))] public sealed partial class UpdateByQueryRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateRequest.g.cs index b1c84b42bce..5addf606009 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateRequest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Requests; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; @@ -116,12 +117,123 @@ public sealed partial class UpdateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Serverless.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } } +internal sealed partial class UpdateRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDetectNoop = System.Text.Json.JsonEncodedText.Encode("detect_noop"); + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropDocAsUpsert = System.Text.Json.JsonEncodedText.Encode("doc_as_upsert"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptedUpsert = System.Text.Json.JsonEncodedText.Encode("scripted_upsert"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropUpsert = System.Text.Json.JsonEncodedText.Encode("upsert"); + + public override UpdateRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDetectNoop = default; + LocalJsonProperty propDoc = default; + LocalJsonProperty propDocAsUpsert = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propScriptedUpsert = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propUpsert = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetectNoop.TryRead(ref reader, options, PropDetectNoop)) + { + continue; + } + + if (propDoc.TryRead(ref reader, options, PropDoc, typeof(SourceMarker))) + { + continue; + } + + if (propDocAsUpsert.TryRead(ref reader, options, PropDocAsUpsert)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptedUpsert.TryRead(ref reader, options, PropScriptedUpsert)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propUpsert.TryRead(ref reader, options, PropUpsert, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateRequest + { + DetectNoop = propDetectNoop.Value + , + Doc = propDoc.Value + , + DocAsUpsert = propDocAsUpsert.Value + , + Script = propScript.Value + , + ScriptedUpsert = propScriptedUpsert.Value + , + Source = propSource.Value + , + Upsert = propUpsert.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetectNoop, value.DetectNoop); + writer.WriteProperty(options, PropDoc, value.Doc, typeof(SourceMarker)); + writer.WriteProperty(options, PropDocAsUpsert, value.DocAsUpsert); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptedUpsert, value.ScriptedUpsert); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropUpsert, value.Upsert, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class UpdateRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(UpdateRequest<,>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(UpdateRequestConverter<,>).MakeGenericType(args[0], args[1]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Update a document. /// Updates a document by running a script or passing a partial document. /// /// +[JsonConverter(typeof(UpdateRequestConverterFactory))] public sealed partial class UpdateRequest : PlainRequest { public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, Elastic.Clients.Elasticsearch.Serverless.Id id) : base(r => r.Required("index", index).Required("id", id)) @@ -141,7 +253,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Only perform the operation if the document has this primary term. /// /// - [JsonIgnore] public long? IfPrimaryTerm { get => Q("if_primary_term"); set => Q("if_primary_term", value); } /// @@ -149,7 +260,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Only perform the operation if the document has this sequence number. /// /// - [JsonIgnore] public long? IfSeqNo { get => Q("if_seq_no"); set => Q("if_seq_no", value); } /// @@ -157,7 +267,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// The script language. /// /// - [JsonIgnore] public string? Lang { get => Q("lang"); set => Q("lang", value); } /// @@ -167,7 +276,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// visible to search, if 'false' do nothing with refreshes. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } /// @@ -175,7 +283,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// If true, the destination must be an index alias. /// /// - [JsonIgnore] public bool? RequireAlias { get => Q("require_alias"); set => Q("require_alias", value); } /// @@ -183,7 +290,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Specify how many times should the operation be retried when a conflict occurs. /// /// - [JsonIgnore] public int? RetryOnConflict { get => Q("retry_on_conflict"); set => Q("retry_on_conflict", value); } /// @@ -191,7 +297,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -199,7 +304,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Specify the source fields you want to exclude. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -207,7 +311,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Specify the source fields you want to retrieve. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -217,7 +320,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// The actual wait time could be longer, particularly when multiple waits occur. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -227,7 +329,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// (number_of_replicas+1). Defaults to 1 meaning the primary shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Serverless.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } /// @@ -236,7 +337,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// to 'noop' if no change to the document occurred. /// /// - [JsonInclude, JsonPropertyName("detect_noop")] public bool? DetectNoop { get; set; } /// @@ -244,8 +344,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// A partial update to an existing document. /// /// - [JsonInclude, JsonPropertyName("doc")] - [SourceConverter] public TPartialDocument? Doc { get; set; } /// @@ -253,7 +351,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Set to true to use the contents of 'doc' as the value of 'upsert' /// /// - [JsonInclude, JsonPropertyName("doc_as_upsert")] public bool? DocAsUpsert { get; set; } /// @@ -261,7 +358,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Script to execute to update the document. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } /// @@ -269,7 +365,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// Set to true to execute the script whether or not the document exists. /// /// - [JsonInclude, JsonPropertyName("scripted_upsert")] public bool? ScriptedUpsert { get; set; } /// @@ -278,7 +373,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// list of the fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// @@ -287,8 +381,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.Serverless.IndexName index, E /// new document. If the document exists, the 'script' is executed. /// /// - [JsonInclude, JsonPropertyName("upsert")] - [SourceConverter] public TDocument? Upsert { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateResponse.g.cs index d25c3fdaaf5..e395184203f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/UpdateResponse.g.cs @@ -18,32 +18,157 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class UpdateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropGet = System.Text.Json.JsonEncodedText.Encode("get"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override UpdateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propForcedRefresh = default; + LocalJsonProperty?> propGet = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propResult = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propShards = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propGet.TryRead(ref reader, options, PropGet)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Get = propGet.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropGet, value.Get); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class UpdateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(UpdateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(UpdateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(UpdateResponseConverterFactory))] public sealed partial class UpdateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("get")] public Elastic.Clients.Elasticsearch.Serverless.InlineGet? Get { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Serverless.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.Serverless.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackInfoResponse.g.cs index a189fb4d492..7496e38e031 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackInfoResponse.g.cs @@ -18,22 +18,85 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Xpack; +internal sealed partial class XpackInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBuild = System.Text.Json.JsonEncodedText.Encode("build"); + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + private static readonly System.Text.Json.JsonEncodedText PropLicense = System.Text.Json.JsonEncodedText.Encode("license"); + private static readonly System.Text.Json.JsonEncodedText PropTagline = System.Text.Json.JsonEncodedText.Encode("tagline"); + + public override XpackInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBuild = default; + LocalJsonProperty propFeatures = default; + LocalJsonProperty propLicense = default; + LocalJsonProperty propTagline = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuild.TryRead(ref reader, options, PropBuild)) + { + continue; + } + + if (propFeatures.TryRead(ref reader, options, PropFeatures)) + { + continue; + } + + if (propLicense.TryRead(ref reader, options, PropLicense)) + { + continue; + } + + if (propTagline.TryRead(ref reader, options, PropTagline)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new XpackInfoResponse + { + Build = propBuild.Value +, + Features = propFeatures.Value +, + License = propLicense.Value +, + Tagline = propTagline.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, XpackInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBuild, value.Build); + writer.WriteProperty(options, PropFeatures, value.Features); + writer.WriteProperty(options, PropLicense, value.License); + writer.WriteProperty(options, PropTagline, value.Tagline); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackInfoResponseConverter))] public sealed partial class XpackInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("build")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.BuildInformation Build { get; init; } - [JsonInclude, JsonPropertyName("features")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Features Features { get; init; } - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.MinimalLicenseInformation License { get; init; } - [JsonInclude, JsonPropertyName("tagline")] public string Tagline { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackUsageResponse.g.cs index 37622ed3d43..13761b0f131 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/Xpack/XpackUsageResponse.g.cs @@ -18,72 +18,360 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Serverless.Xpack; +internal sealed partial class XpackUsageResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregateMetric = System.Text.Json.JsonEncodedText.Encode("aggregate_metric"); + private static readonly System.Text.Json.JsonEncodedText PropAnalytics = System.Text.Json.JsonEncodedText.Encode("analytics"); + private static readonly System.Text.Json.JsonEncodedText PropArchive = System.Text.Json.JsonEncodedText.Encode("archive"); + private static readonly System.Text.Json.JsonEncodedText PropCcr = System.Text.Json.JsonEncodedText.Encode("ccr"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrame = System.Text.Json.JsonEncodedText.Encode("data_frame"); + private static readonly System.Text.Json.JsonEncodedText PropDataScience = System.Text.Json.JsonEncodedText.Encode("data_science"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropDataTiers = System.Text.Json.JsonEncodedText.Encode("data_tiers"); + private static readonly System.Text.Json.JsonEncodedText PropEnrich = System.Text.Json.JsonEncodedText.Encode("enrich"); + private static readonly System.Text.Json.JsonEncodedText PropEql = System.Text.Json.JsonEncodedText.Encode("eql"); + private static readonly System.Text.Json.JsonEncodedText PropFlattened = System.Text.Json.JsonEncodedText.Encode("flattened"); + private static readonly System.Text.Json.JsonEncodedText PropFrozenIndices = System.Text.Json.JsonEncodedText.Encode("frozen_indices"); + private static readonly System.Text.Json.JsonEncodedText PropGraph = System.Text.Json.JsonEncodedText.Encode("graph"); + private static readonly System.Text.Json.JsonEncodedText PropHealthApi = System.Text.Json.JsonEncodedText.Encode("health_api"); + private static readonly System.Text.Json.JsonEncodedText PropIlm = System.Text.Json.JsonEncodedText.Encode("ilm"); + private static readonly System.Text.Json.JsonEncodedText PropLogstash = System.Text.Json.JsonEncodedText.Encode("logstash"); + private static readonly System.Text.Json.JsonEncodedText PropMl = System.Text.Json.JsonEncodedText.Encode("ml"); + private static readonly System.Text.Json.JsonEncodedText PropMonitoring = System.Text.Json.JsonEncodedText.Encode("monitoring"); + private static readonly System.Text.Json.JsonEncodedText PropRollup = System.Text.Json.JsonEncodedText.Encode("rollup"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeFields = System.Text.Json.JsonEncodedText.Encode("runtime_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchableSnapshots = System.Text.Json.JsonEncodedText.Encode("searchable_snapshots"); + private static readonly System.Text.Json.JsonEncodedText PropSecurity = System.Text.Json.JsonEncodedText.Encode("security"); + private static readonly System.Text.Json.JsonEncodedText PropSlm = System.Text.Json.JsonEncodedText.Encode("slm"); + private static readonly System.Text.Json.JsonEncodedText PropSpatial = System.Text.Json.JsonEncodedText.Encode("spatial"); + private static readonly System.Text.Json.JsonEncodedText PropSql = System.Text.Json.JsonEncodedText.Encode("sql"); + private static readonly System.Text.Json.JsonEncodedText PropTransform = System.Text.Json.JsonEncodedText.Encode("transform"); + private static readonly System.Text.Json.JsonEncodedText PropVectors = System.Text.Json.JsonEncodedText.Encode("vectors"); + private static readonly System.Text.Json.JsonEncodedText PropVotingOnly = System.Text.Json.JsonEncodedText.Encode("voting_only"); + private static readonly System.Text.Json.JsonEncodedText PropWatcher = System.Text.Json.JsonEncodedText.Encode("watcher"); + + public override XpackUsageResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregateMetric = default; + LocalJsonProperty propAnalytics = default; + LocalJsonProperty propArchive = default; + LocalJsonProperty propCcr = default; + LocalJsonProperty propDataFrame = default; + LocalJsonProperty propDataScience = default; + LocalJsonProperty propDataStreams = default; + LocalJsonProperty propDataTiers = default; + LocalJsonProperty propEnrich = default; + LocalJsonProperty propEql = default; + LocalJsonProperty propFlattened = default; + LocalJsonProperty propFrozenIndices = default; + LocalJsonProperty propGraph = default; + LocalJsonProperty propHealthApi = default; + LocalJsonProperty propIlm = default; + LocalJsonProperty propLogstash = default; + LocalJsonProperty propMl = default; + LocalJsonProperty propMonitoring = default; + LocalJsonProperty propRollup = default; + LocalJsonProperty propRuntimeFields = default; + LocalJsonProperty propSearchableSnapshots = default; + LocalJsonProperty propSecurity = default; + LocalJsonProperty propSlm = default; + LocalJsonProperty propSpatial = default; + LocalJsonProperty propSql = default; + LocalJsonProperty propTransform = default; + LocalJsonProperty propVectors = default; + LocalJsonProperty propVotingOnly = default; + LocalJsonProperty propWatcher = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregateMetric.TryRead(ref reader, options, PropAggregateMetric)) + { + continue; + } + + if (propAnalytics.TryRead(ref reader, options, PropAnalytics)) + { + continue; + } + + if (propArchive.TryRead(ref reader, options, PropArchive)) + { + continue; + } + + if (propCcr.TryRead(ref reader, options, PropCcr)) + { + continue; + } + + if (propDataFrame.TryRead(ref reader, options, PropDataFrame)) + { + continue; + } + + if (propDataScience.TryRead(ref reader, options, PropDataScience)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propDataTiers.TryRead(ref reader, options, PropDataTiers)) + { + continue; + } + + if (propEnrich.TryRead(ref reader, options, PropEnrich)) + { + continue; + } + + if (propEql.TryRead(ref reader, options, PropEql)) + { + continue; + } + + if (propFlattened.TryRead(ref reader, options, PropFlattened)) + { + continue; + } + + if (propFrozenIndices.TryRead(ref reader, options, PropFrozenIndices)) + { + continue; + } + + if (propGraph.TryRead(ref reader, options, PropGraph)) + { + continue; + } + + if (propHealthApi.TryRead(ref reader, options, PropHealthApi)) + { + continue; + } + + if (propIlm.TryRead(ref reader, options, PropIlm)) + { + continue; + } + + if (propLogstash.TryRead(ref reader, options, PropLogstash)) + { + continue; + } + + if (propMl.TryRead(ref reader, options, PropMl)) + { + continue; + } + + if (propMonitoring.TryRead(ref reader, options, PropMonitoring)) + { + continue; + } + + if (propRollup.TryRead(ref reader, options, PropRollup)) + { + continue; + } + + if (propRuntimeFields.TryRead(ref reader, options, PropRuntimeFields)) + { + continue; + } + + if (propSearchableSnapshots.TryRead(ref reader, options, PropSearchableSnapshots)) + { + continue; + } + + if (propSecurity.TryRead(ref reader, options, PropSecurity)) + { + continue; + } + + if (propSlm.TryRead(ref reader, options, PropSlm)) + { + continue; + } + + if (propSpatial.TryRead(ref reader, options, PropSpatial)) + { + continue; + } + + if (propSql.TryRead(ref reader, options, PropSql)) + { + continue; + } + + if (propTransform.TryRead(ref reader, options, PropTransform)) + { + continue; + } + + if (propVectors.TryRead(ref reader, options, PropVectors)) + { + continue; + } + + if (propVotingOnly.TryRead(ref reader, options, PropVotingOnly)) + { + continue; + } + + if (propWatcher.TryRead(ref reader, options, PropWatcher)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new XpackUsageResponse + { + AggregateMetric = propAggregateMetric.Value +, + Analytics = propAnalytics.Value +, + Archive = propArchive.Value +, + Ccr = propCcr.Value +, + DataFrame = propDataFrame.Value +, + DataScience = propDataScience.Value +, + DataStreams = propDataStreams.Value +, + DataTiers = propDataTiers.Value +, + Enrich = propEnrich.Value +, + Eql = propEql.Value +, + Flattened = propFlattened.Value +, + FrozenIndices = propFrozenIndices.Value +, + Graph = propGraph.Value +, + HealthApi = propHealthApi.Value +, + Ilm = propIlm.Value +, + Logstash = propLogstash.Value +, + Ml = propMl.Value +, + Monitoring = propMonitoring.Value +, + Rollup = propRollup.Value +, + RuntimeFields = propRuntimeFields.Value +, + SearchableSnapshots = propSearchableSnapshots.Value +, + Security = propSecurity.Value +, + Slm = propSlm.Value +, + Spatial = propSpatial.Value +, + Sql = propSql.Value +, + Transform = propTransform.Value +, + Vectors = propVectors.Value +, + VotingOnly = propVotingOnly.Value +, + Watcher = propWatcher.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, XpackUsageResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregateMetric, value.AggregateMetric); + writer.WriteProperty(options, PropAnalytics, value.Analytics); + writer.WriteProperty(options, PropArchive, value.Archive); + writer.WriteProperty(options, PropCcr, value.Ccr); + writer.WriteProperty(options, PropDataFrame, value.DataFrame); + writer.WriteProperty(options, PropDataScience, value.DataScience); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropDataTiers, value.DataTiers); + writer.WriteProperty(options, PropEnrich, value.Enrich); + writer.WriteProperty(options, PropEql, value.Eql); + writer.WriteProperty(options, PropFlattened, value.Flattened); + writer.WriteProperty(options, PropFrozenIndices, value.FrozenIndices); + writer.WriteProperty(options, PropGraph, value.Graph); + writer.WriteProperty(options, PropHealthApi, value.HealthApi); + writer.WriteProperty(options, PropIlm, value.Ilm); + writer.WriteProperty(options, PropLogstash, value.Logstash); + writer.WriteProperty(options, PropMl, value.Ml); + writer.WriteProperty(options, PropMonitoring, value.Monitoring); + writer.WriteProperty(options, PropRollup, value.Rollup); + writer.WriteProperty(options, PropRuntimeFields, value.RuntimeFields); + writer.WriteProperty(options, PropSearchableSnapshots, value.SearchableSnapshots); + writer.WriteProperty(options, PropSecurity, value.Security); + writer.WriteProperty(options, PropSlm, value.Slm); + writer.WriteProperty(options, PropSpatial, value.Spatial); + writer.WriteProperty(options, PropSql, value.Sql); + writer.WriteProperty(options, PropTransform, value.Transform); + writer.WriteProperty(options, PropVectors, value.Vectors); + writer.WriteProperty(options, PropVotingOnly, value.VotingOnly); + writer.WriteProperty(options, PropWatcher, value.Watcher); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackUsageResponseConverter))] public sealed partial class XpackUsageResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregate_metric")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base AggregateMetric { get; init; } - [JsonInclude, JsonPropertyName("analytics")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Analytics Analytics { get; init; } - [JsonInclude, JsonPropertyName("archive")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Archive Archive { get; init; } - [JsonInclude, JsonPropertyName("ccr")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Ccr Ccr { get; init; } - [JsonInclude, JsonPropertyName("data_frame")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base? DataFrame { get; init; } - [JsonInclude, JsonPropertyName("data_science")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base? DataScience { get; init; } - [JsonInclude, JsonPropertyName("data_streams")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.DataStreams? DataStreams { get; init; } - [JsonInclude, JsonPropertyName("data_tiers")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.DataTiers DataTiers { get; init; } - [JsonInclude, JsonPropertyName("enrich")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base? Enrich { get; init; } - [JsonInclude, JsonPropertyName("eql")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Eql Eql { get; init; } - [JsonInclude, JsonPropertyName("flattened")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Flattened? Flattened { get; init; } - [JsonInclude, JsonPropertyName("frozen_indices")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.FrozenIndices FrozenIndices { get; init; } - [JsonInclude, JsonPropertyName("graph")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base Graph { get; init; } - [JsonInclude, JsonPropertyName("health_api")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.HealthStatistics? HealthApi { get; init; } - [JsonInclude, JsonPropertyName("ilm")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Ilm Ilm { get; init; } - [JsonInclude, JsonPropertyName("logstash")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base Logstash { get; init; } - [JsonInclude, JsonPropertyName("ml")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.MachineLearning Ml { get; init; } - [JsonInclude, JsonPropertyName("monitoring")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Monitoring Monitoring { get; init; } - [JsonInclude, JsonPropertyName("rollup")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base Rollup { get; init; } - [JsonInclude, JsonPropertyName("runtime_fields")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.RuntimeFieldTypes? RuntimeFields { get; init; } - [JsonInclude, JsonPropertyName("searchable_snapshots")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.SearchableSnapshots SearchableSnapshots { get; init; } - [JsonInclude, JsonPropertyName("security")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Security Security { get; init; } - [JsonInclude, JsonPropertyName("slm")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Slm Slm { get; init; } - [JsonInclude, JsonPropertyName("spatial")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base Spatial { get; init; } - [JsonInclude, JsonPropertyName("sql")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Sql Sql { get; init; } - [JsonInclude, JsonPropertyName("transform")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base Transform { get; init; } - [JsonInclude, JsonPropertyName("vectors")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Vector? Vectors { get; init; } - [JsonInclude, JsonPropertyName("voting_only")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Base VotingOnly { get; init; } - [JsonInclude, JsonPropertyName("watcher")] public Elastic.Clients.Elasticsearch.Serverless.Xpack.Watcher Watcher { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs index ca977c75a2c..f9e840fd59a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class AdjacencyMatrixAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "adjacency_matrix"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs index 21d617735bd..1161a7e292f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class AdjacencyMatrixBucketConverter : JsonConverter +internal sealed partial class AdjacencyMatrixBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override AdjacencyMatrixBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override AdjacencyMatrixBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new AdjacencyMatrixBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AdjacencyMatrixBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, AdjacencyMatrixBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AdjacencyMatrixBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'AdjacencyMatrixBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AggregateDictionary.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AggregateDictionary.g.cs index 7f1f89d7900..c27f5ade03a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AggregateDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AggregateDictionary.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -33,6 +34,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; public partial interface IAggregate { + public string? Type { get; } } [JsonConverter(typeof(AggregateDictionaryConverter))] @@ -115,530 +117,338 @@ public AggregateDictionary(IReadOnlyDictionary backingDictio private T? TryGet(string key) where T : class, IAggregate => BackingDictionary.TryGetValue(key, out var value) ? value as T : null; } -internal sealed partial class AggregateDictionaryConverter : JsonConverter +internal sealed partial class AggregateDictionaryConverter : System.Text.Json.Serialization.JsonConverter { - public override AggregateDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override AggregateDictionary Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var dictionary = new Dictionary(); - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var dictionary = new System.Collections.Generic.Dictionary(); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); - var name = reader.GetString(); - reader.Read(); - ReadItem(ref reader, options, dictionary, name); + ReadItem(ref reader, options, out string name, out IAggregate value); + dictionary[name] = value; } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); return new AggregateDictionary(dictionary); } - public override void Write(Utf8JsonWriter writer, AggregateDictionary value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AggregateDictionary value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'AggregateDictionary' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + foreach (var pair in value) + { + WriteItem(writer, options, pair.Key, pair.Value); + } + + writer.WriteEndObject(); } - public static void ReadItem(ref Utf8JsonReader reader, JsonSerializerOptions options, Dictionary dictionary, string name) + internal static void ReadItem(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, out string name, out IAggregate value) { - var nameParts = name.Split('#'); - if (nameParts.Length != 2) - throw new JsonException($"Unable to parse typed-key '{name}'."); - var type = nameParts[0]; - switch (type) + reader.ReadPropertyName(options, out string key); + reader.Read(); + var parts = key.Split('#'); + if (parts.Length != 2) { - case "adjacency_matrix": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "auto_date_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "avg": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "boxplot": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "bucket_metric_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "cardinality": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "children": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "composite": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "simple_long_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "date_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "date_range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "derivative": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "dterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "extended_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "extended_stats_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "filter": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "filters": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "frequent_item_sets": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_bounds": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_centroid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_distance": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geohash_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geohex_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_line": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geotile_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "global": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "hdr_percentile_ranks": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "hdr_percentiles": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "inference": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "ip_prefix": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "ip_range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "lrareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "lterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "matrix_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "max": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "median_absolute_deviation": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "min": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "missing": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "multi_terms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "nested": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "parent": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "percentiles_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "rate": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "reverse_nested": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sampler": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "scripted_metric": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "siglterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sigsterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "simple_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "stats_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "srareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "string_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sum": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "tdigest_percentile_ranks": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "tdigest_percentiles": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "time_series": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "top_hits": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "top_metrics": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "t_test": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umrareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "unmapped_sampler": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umsigterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "value_count": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "variable_width_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + throw new System.Text.Json.JsonException($"Unable to parse typed-key '{key}' for variant '{nameof(IAggregate)}'."); + } - case "weighted_avg": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + var discriminator = parts[0]; + name = parts[1]; + value = discriminator switch + { + "adjacency_matrix" => reader.ReadValue(options), + "auto_date_histogram" => reader.ReadValue(options), + "avg" => reader.ReadValue(options), + "boxplot" => reader.ReadValue(options), + "bucket_metric_value" => reader.ReadValue(options), + "cardinality" => reader.ReadValue(options), + "children" => reader.ReadValue(options), + "composite" => reader.ReadValue(options), + "simple_long_value" => reader.ReadValue(options), + "date_histogram" => reader.ReadValue(options), + "date_range" => reader.ReadValue(options), + "derivative" => reader.ReadValue(options), + "dterms" => reader.ReadValue(options), + "extended_stats" => reader.ReadValue(options), + "extended_stats_bucket" => reader.ReadValue(options), + "filter" => reader.ReadValue(options), + "filters" => reader.ReadValue(options), + "frequent_item_sets" => reader.ReadValue(options), + "geo_bounds" => reader.ReadValue(options), + "geo_centroid" => reader.ReadValue(options), + "geo_distance" => reader.ReadValue(options), + "geohash_grid" => reader.ReadValue(options), + "geohex_grid" => reader.ReadValue(options), + "geo_line" => reader.ReadValue(options), + "geotile_grid" => reader.ReadValue(options), + "global" => reader.ReadValue(options), + "hdr_percentile_ranks" => reader.ReadValue(options), + "hdr_percentiles" => reader.ReadValue(options), + "histogram" => reader.ReadValue(options), + "inference" => reader.ReadValue(options), + "ip_prefix" => reader.ReadValue(options), + "ip_range" => reader.ReadValue(options), + "lrareterms" => reader.ReadValue(options), + "lterms" => reader.ReadValue(options), + "matrix_stats" => reader.ReadValue(options), + "max" => reader.ReadValue(options), + "median_absolute_deviation" => reader.ReadValue(options), + "min" => reader.ReadValue(options), + "missing" => reader.ReadValue(options), + "multi_terms" => reader.ReadValue(options), + "nested" => reader.ReadValue(options), + "parent" => reader.ReadValue(options), + "percentiles_bucket" => reader.ReadValue(options), + "range" => reader.ReadValue(options), + "rate" => reader.ReadValue(options), + "reverse_nested" => reader.ReadValue(options), + "sampler" => reader.ReadValue(options), + "scripted_metric" => reader.ReadValue(options), + "siglterms" => reader.ReadValue(options), + "sigsterms" => reader.ReadValue(options), + "simple_value" => reader.ReadValue(options), + "stats" => reader.ReadValue(options), + "stats_bucket" => reader.ReadValue(options), + "srareterms" => reader.ReadValue(options), + "string_stats" => reader.ReadValue(options), + "sterms" => reader.ReadValue(options), + "sum" => reader.ReadValue(options), + "tdigest_percentile_ranks" => reader.ReadValue(options), + "tdigest_percentiles" => reader.ReadValue(options), + "time_series" => reader.ReadValue(options), + "top_hits" => reader.ReadValue(options), + "top_metrics" => reader.ReadValue(options), + "t_test" => reader.ReadValue(options), + "umrareterms" => reader.ReadValue(options), + "unmapped_sampler" => reader.ReadValue(options), + "umsigterms" => reader.ReadValue(options), + "umterms" => reader.ReadValue(options), + "value_count" => reader.ReadValue(options), + "variable_width_histogram" => reader.ReadValue(options), + "weighted_avg" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IAggregate)}'.") + }; + } + internal static void WriteItem(System.Text.Json.Utf8JsonWriter writer, System.Text.Json.JsonSerializerOptions options, string name, IAggregate value) + { + var key = value.Type + '#' + name; + switch (value) + { + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketMetricValueAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.DoubleTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.FilterAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentileRanksAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.HdrPercentilesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.LongTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantLongTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantStringTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.SimpleValueAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentileRanksAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TDigestPercentilesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TimeSeriesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSamplerAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedSignificantTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.UnmappedTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregate v: + writer.WriteProperty(options, key, v); + break; default: - throw new NotSupportedException($"The tagged variant '{type}' is currently not supported."); + throw new System.Text.Json.JsonException($"Variant '{0}' is not supported for type '{nameof(IAggregate)}'."); } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/Aggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/Aggregation.g.cs index 9e2e2f1a0fb..1404179b9fc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/Aggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/Aggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Aggregation(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Aggregation() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Aggregation AdjacencyMatrix(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => new Aggregation("adjacency_matrix", adjacencyMatrixAggregation); public static Aggregation AutoDateHistogram(Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => new Aggregation("auto_date_histogram", autoDateHistogramAggregation); @@ -143,797 +148,922 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class AggregationConverter : JsonConverter +internal sealed partial class AggregationConverter : System.Text.Json.Serialization.JsonConverter { - public override Aggregation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText VariantAdjacencyMatrix = System.Text.Json.JsonEncodedText.Encode("adjacency_matrix"); + private static readonly System.Text.Json.JsonEncodedText VariantAutoDateHistogram = System.Text.Json.JsonEncodedText.Encode("auto_date_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + private static readonly System.Text.Json.JsonEncodedText VariantAvgBucket = System.Text.Json.JsonEncodedText.Encode("avg_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantBoxplot = System.Text.Json.JsonEncodedText.Encode("boxplot"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketScript = System.Text.Json.JsonEncodedText.Encode("bucket_script"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketSelector = System.Text.Json.JsonEncodedText.Encode("bucket_selector"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketSort = System.Text.Json.JsonEncodedText.Encode("bucket_sort"); + private static readonly System.Text.Json.JsonEncodedText VariantCardinality = System.Text.Json.JsonEncodedText.Encode("cardinality"); + private static readonly System.Text.Json.JsonEncodedText VariantChildren = System.Text.Json.JsonEncodedText.Encode("children"); + private static readonly System.Text.Json.JsonEncodedText VariantComposite = System.Text.Json.JsonEncodedText.Encode("composite"); + private static readonly System.Text.Json.JsonEncodedText VariantCumulativeCardinality = System.Text.Json.JsonEncodedText.Encode("cumulative_cardinality"); + private static readonly System.Text.Json.JsonEncodedText VariantCumulativeSum = System.Text.Json.JsonEncodedText.Encode("cumulative_sum"); + private static readonly System.Text.Json.JsonEncodedText VariantDateHistogram = System.Text.Json.JsonEncodedText.Encode("date_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantDateRange = System.Text.Json.JsonEncodedText.Encode("date_range"); + private static readonly System.Text.Json.JsonEncodedText VariantDerivative = System.Text.Json.JsonEncodedText.Encode("derivative"); + private static readonly System.Text.Json.JsonEncodedText VariantDiversifiedSampler = System.Text.Json.JsonEncodedText.Encode("diversified_sampler"); + private static readonly System.Text.Json.JsonEncodedText VariantExtendedStats = System.Text.Json.JsonEncodedText.Encode("extended_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantExtendedStatsBucket = System.Text.Json.JsonEncodedText.Encode("extended_stats_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText VariantFilters = System.Text.Json.JsonEncodedText.Encode("filters"); + private static readonly System.Text.Json.JsonEncodedText VariantFrequentItemSets = System.Text.Json.JsonEncodedText.Encode("frequent_item_sets"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoBounds = System.Text.Json.JsonEncodedText.Encode("geo_bounds"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoCentroid = System.Text.Json.JsonEncodedText.Encode("geo_centroid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoDistance = System.Text.Json.JsonEncodedText.Encode("geo_distance"); + private static readonly System.Text.Json.JsonEncodedText VariantGeohashGrid = System.Text.Json.JsonEncodedText.Encode("geohash_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeohexGrid = System.Text.Json.JsonEncodedText.Encode("geohex_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoLine = System.Text.Json.JsonEncodedText.Encode("geo_line"); + private static readonly System.Text.Json.JsonEncodedText VariantGeotileGrid = System.Text.Json.JsonEncodedText.Encode("geotile_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText VariantHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantInference = System.Text.Json.JsonEncodedText.Encode("inference"); + private static readonly System.Text.Json.JsonEncodedText VariantIpPrefix = System.Text.Json.JsonEncodedText.Encode("ip_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantIpRange = System.Text.Json.JsonEncodedText.Encode("ip_range"); + private static readonly System.Text.Json.JsonEncodedText VariantLine = System.Text.Json.JsonEncodedText.Encode("line"); + private static readonly System.Text.Json.JsonEncodedText VariantMatrixStats = System.Text.Json.JsonEncodedText.Encode("matrix_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxBucket = System.Text.Json.JsonEncodedText.Encode("max_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantMedianAbsoluteDeviation = System.Text.Json.JsonEncodedText.Encode("median_absolute_deviation"); + private static readonly System.Text.Json.JsonEncodedText VariantMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText VariantMinBucket = System.Text.Json.JsonEncodedText.Encode("min_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText VariantMovingFn = System.Text.Json.JsonEncodedText.Encode("moving_fn"); + private static readonly System.Text.Json.JsonEncodedText VariantMovingPercentiles = System.Text.Json.JsonEncodedText.Encode("moving_percentiles"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiTerms = System.Text.Json.JsonEncodedText.Encode("multi_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText VariantNormalize = System.Text.Json.JsonEncodedText.Encode("normalize"); + private static readonly System.Text.Json.JsonEncodedText VariantParent = System.Text.Json.JsonEncodedText.Encode("parent"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentileRanks = System.Text.Json.JsonEncodedText.Encode("percentile_ranks"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentiles = System.Text.Json.JsonEncodedText.Encode("percentiles"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentilesBucket = System.Text.Json.JsonEncodedText.Encode("percentiles_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText VariantRareTerms = System.Text.Json.JsonEncodedText.Encode("rare_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantRate = System.Text.Json.JsonEncodedText.Encode("rate"); + private static readonly System.Text.Json.JsonEncodedText VariantReverseNested = System.Text.Json.JsonEncodedText.Encode("reverse_nested"); + private static readonly System.Text.Json.JsonEncodedText VariantSampler = System.Text.Json.JsonEncodedText.Encode("sampler"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptedMetric = System.Text.Json.JsonEncodedText.Encode("scripted_metric"); + private static readonly System.Text.Json.JsonEncodedText VariantSerialDiff = System.Text.Json.JsonEncodedText.Encode("serial_diff"); + private static readonly System.Text.Json.JsonEncodedText VariantSignificantTerms = System.Text.Json.JsonEncodedText.Encode("significant_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantSignificantText = System.Text.Json.JsonEncodedText.Encode("significant_text"); + private static readonly System.Text.Json.JsonEncodedText VariantStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText VariantStatsBucket = System.Text.Json.JsonEncodedText.Encode("stats_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantStringStats = System.Text.Json.JsonEncodedText.Encode("string_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText VariantSumBucket = System.Text.Json.JsonEncodedText.Encode("sum_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText VariantTopHits = System.Text.Json.JsonEncodedText.Encode("top_hits"); + private static readonly System.Text.Json.JsonEncodedText VariantTopMetrics = System.Text.Json.JsonEncodedText.Encode("top_metrics"); + private static readonly System.Text.Json.JsonEncodedText VariantTTest = System.Text.Json.JsonEncodedText.Encode("t_test"); + private static readonly System.Text.Json.JsonEncodedText VariantValueCount = System.Text.Json.JsonEncodedText.Encode("value_count"); + private static readonly System.Text.Json.JsonEncodedText VariantVariableWidthHistogram = System.Text.Json.JsonEncodedText.Encode("variable_width_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantWeightedAvg = System.Text.Json.JsonEncodedText.Encode("weighted_avg"); + + public override Aggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - IDictionary? aggregationsValue = default; - IDictionary? metaValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty?> propMeta = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "aggregations") + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - aggregationsValue = JsonSerializer.Deserialize?>(ref reader, options); continue; } - if (propertyName == "meta") + if (propMeta.TryRead(ref reader, options, PropMeta)) { - metaValue = JsonSerializer.Deserialize?>(ref reader, options); continue; } - if (propertyName == "adjacency_matrix") + if (reader.ValueTextEquals(VariantAdjacencyMatrix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAdjacencyMatrix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "auto_date_histogram") + if (reader.ValueTextEquals(VariantAutoDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAutoDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "avg") + if (reader.ValueTextEquals(VariantAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvg.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "avg_bucket") + if (reader.ValueTextEquals(VariantAvgBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvgBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "boxplot") + if (reader.ValueTextEquals(VariantBoxplot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoxplot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_script") + if (reader.ValueTextEquals(VariantBucketScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_selector") + if (reader.ValueTextEquals(VariantBucketSelector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSelector.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_sort") + if (reader.ValueTextEquals(VariantBucketSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSort.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cardinality") + if (reader.ValueTextEquals(VariantCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "children") + if (reader.ValueTextEquals(VariantChildren)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantChildren.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "composite") + if (reader.ValueTextEquals(VariantComposite)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantComposite.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cumulative_cardinality") + if (reader.ValueTextEquals(VariantCumulativeCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cumulative_sum") + if (reader.ValueTextEquals(VariantCumulativeSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeSum.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_histogram") + if (reader.ValueTextEquals(VariantDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_range") + if (reader.ValueTextEquals(VariantDateRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "derivative") + if (reader.ValueTextEquals(VariantDerivative)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDerivative.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "diversified_sampler") + if (reader.ValueTextEquals(VariantDiversifiedSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDiversifiedSampler.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "extended_stats") + if (reader.ValueTextEquals(VariantExtendedStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "extended_stats_bucket") + if (reader.ValueTextEquals(VariantExtendedStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "filter") + if (reader.ValueTextEquals(VariantFilter)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilter.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "filters") + if (reader.ValueTextEquals(VariantFilters)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilters.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "frequent_item_sets") + if (reader.ValueTextEquals(VariantFrequentItemSets)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequentItemSets.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_bounds") + if (reader.ValueTextEquals(VariantGeoBounds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBounds.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_centroid") + if (reader.ValueTextEquals(VariantGeoCentroid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoCentroid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geohash_grid") + if (reader.ValueTextEquals(VariantGeohashGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohashGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geohex_grid") + if (reader.ValueTextEquals(VariantGeohexGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohexGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_line") + if (reader.ValueTextEquals(VariantGeoLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoLine.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geotile_grid") + if (reader.ValueTextEquals(VariantGeotileGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeotileGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "global") + if (reader.ValueTextEquals(VariantGlobal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGlobal.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "histogram") + if (reader.ValueTextEquals(VariantHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_prefix") + if (reader.ValueTextEquals(VariantIpPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_range") + if (reader.ValueTextEquals(VariantIpRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "line") + if (reader.ValueTextEquals(VariantLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLine.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "matrix_stats") + if (reader.ValueTextEquals(VariantMatrixStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatrixStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "max") + if (reader.ValueTextEquals(VariantMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMax.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "max_bucket") + if (reader.ValueTextEquals(VariantMaxBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "median_absolute_deviation") + if (reader.ValueTextEquals(VariantMedianAbsoluteDeviation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMedianAbsoluteDeviation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "min") + if (reader.ValueTextEquals(VariantMin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "min_bucket") + if (reader.ValueTextEquals(VariantMinBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMinBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "missing") + if (reader.ValueTextEquals(VariantMissing)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMissing.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "moving_fn") + if (reader.ValueTextEquals(VariantMovingFn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingFn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "moving_percentiles") + if (reader.ValueTextEquals(VariantMovingPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_terms") + if (reader.ValueTextEquals(VariantMultiTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "normalize") + if (reader.ValueTextEquals(VariantNormalize)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNormalize.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "parent") + if (reader.ValueTextEquals(VariantParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentile_ranks") + if (reader.ValueTextEquals(VariantPercentileRanks)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentileRanks.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentiles") + if (reader.ValueTextEquals(VariantPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentiles_bucket") + if (reader.ValueTextEquals(VariantPercentilesBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentilesBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rare_terms") + if (reader.ValueTextEquals(VariantRareTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRareTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rate") + if (reader.ValueTextEquals(VariantRate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "reverse_nested") + if (reader.ValueTextEquals(VariantReverseNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReverseNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sampler") + if (reader.ValueTextEquals(VariantSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSampler.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "scripted_metric") + if (reader.ValueTextEquals(VariantScriptedMetric)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptedMetric.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "serial_diff") + if (reader.ValueTextEquals(VariantSerialDiff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSerialDiff.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "significant_terms") + if (reader.ValueTextEquals(VariantSignificantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "significant_text") + if (reader.ValueTextEquals(VariantSignificantText)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantText.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stats") + if (reader.ValueTextEquals(VariantStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stats_bucket") + if (reader.ValueTextEquals(VariantStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "string_stats") + if (reader.ValueTextEquals(VariantStringStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStringStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sum") + if (reader.ValueTextEquals(VariantSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSum.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sum_bucket") + if (reader.ValueTextEquals(VariantSumBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSumBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "top_hits") + if (reader.ValueTextEquals(VariantTopHits)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopHits.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "top_metrics") + if (reader.ValueTextEquals(VariantTopMetrics)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopMetrics.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "t_test") + if (reader.ValueTextEquals(VariantTTest)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTTest.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "value_count") + if (reader.ValueTextEquals(VariantValueCount)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantValueCount.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "variable_width_histogram") + if (reader.ValueTextEquals(VariantVariableWidthHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantVariableWidthHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "weighted_avg") + if (reader.ValueTextEquals(VariantWeightedAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeightedAvg.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Aggregation' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Aggregation(variantNameValue, variantValue); - result.Aggregations = aggregationsValue; - result.Meta = metaValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Aggregation + { + VariantType = variantType, + Variant = variant, + Aggregations = propAggregations.Value + , + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, Aggregation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Aggregation value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - - if (value.Meta is not null) + switch (value.VariantType) { - writer.WritePropertyName("meta"); - JsonSerializer.Serialize(writer, value.Meta, options); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "adjacency_matrix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation)value.Variant, options); - break; - case "auto_date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation)value.Variant, options); - break; - case "avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation)value.Variant, options); - break; - case "avg_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation)value.Variant, options); - break; - case "boxplot": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation)value.Variant, options); - break; - case "bucket_script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation)value.Variant, options); - break; - case "bucket_selector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation)value.Variant, options); - break; - case "bucket_sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation)value.Variant, options); - break; - case "cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation)value.Variant, options); - break; - case "children": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation)value.Variant, options); - break; - case "composite": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation)value.Variant, options); - break; - case "cumulative_cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation)value.Variant, options); - break; - case "cumulative_sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation)value.Variant, options); - break; - case "date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation)value.Variant, options); - break; - case "date_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation)value.Variant, options); - break; - case "derivative": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation)value.Variant, options); - break; - case "diversified_sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation)value.Variant, options); - break; - case "extended_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation)value.Variant, options); - break; - case "extended_stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation)value.Variant, options); - break; - case "filter": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query)value.Variant, options); - break; - case "filters": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation)value.Variant, options); - break; - case "frequent_item_sets": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation)value.Variant, options); - break; - case "geo_bounds": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation)value.Variant, options); - break; - case "geo_centroid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation)value.Variant, options); - break; - case "geohash_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation)value.Variant, options); - break; - case "geohex_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation)value.Variant, options); - break; - case "geo_line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "geotile_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation)value.Variant, options); - break; - case "global": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation)value.Variant, options); - break; - case "histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation)value.Variant, options); - break; - case "ip_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation)value.Variant, options); - break; - case "ip_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation)value.Variant, options); - break; - case "line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "matrix_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation)value.Variant, options); - break; - case "max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation)value.Variant, options); - break; - case "max_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation)value.Variant, options); - break; - case "median_absolute_deviation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation)value.Variant, options); - break; - case "min": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation)value.Variant, options); - break; - case "min_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation)value.Variant, options); - break; - case "missing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation)value.Variant, options); - break; - case "moving_fn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation)value.Variant, options); - break; - case "moving_percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation)value.Variant, options); - break; - case "multi_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation)value.Variant, options); - break; - case "normalize": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation)value.Variant, options); - break; - case "parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation)value.Variant, options); - break; - case "percentile_ranks": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation)value.Variant, options); - break; - case "percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation)value.Variant, options); - break; - case "percentiles_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation)value.Variant, options); - break; - case "range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation)value.Variant, options); - break; - case "rare_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation)value.Variant, options); - break; - case "rate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation)value.Variant, options); - break; - case "reverse_nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation)value.Variant, options); - break; - case "sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation)value.Variant, options); - break; - case "scripted_metric": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation)value.Variant, options); - break; - case "serial_diff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation)value.Variant, options); - break; - case "significant_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation)value.Variant, options); - break; - case "significant_text": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation)value.Variant, options); - break; - case "stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation)value.Variant, options); - break; - case "stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation)value.Variant, options); - break; - case "string_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation)value.Variant, options); - break; - case "sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation)value.Variant, options); - break; - case "sum_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation)value.Variant, options); - break; - case "top_hits": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation)value.Variant, options); - break; - case "top_metrics": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation)value.Variant, options); - break; - case "t_test": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation)value.Variant, options); - break; - case "value_count": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation)value.Variant, options); - break; - case "variable_width_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation)value.Variant, options); - break; - case "weighted_avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation)value.Variant, options); - break; - } + case "": + break; + case "adjacency_matrix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AdjacencyMatrixAggregation?)value.Variant); + break; + case "auto_date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AutoDateHistogramAggregation?)value.Variant); + break; + case "avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageAggregation?)value.Variant); + break; + case "avg_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.AverageBucketAggregation?)value.Variant); + break; + case "boxplot": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BoxplotAggregation?)value.Variant); + break; + case "bucket_script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketScriptAggregation?)value.Variant); + break; + case "bucket_selector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSelectorAggregation?)value.Variant); + break; + case "bucket_sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.BucketSortAggregation?)value.Variant); + break; + case "cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CardinalityAggregation?)value.Variant); + break; + case "children": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChildrenAggregation?)value.Variant); + break; + case "composite": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CompositeAggregation?)value.Variant); + break; + case "cumulative_cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeCardinalityAggregation?)value.Variant); + break; + case "cumulative_sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.CumulativeSumAggregation?)value.Variant); + break; + case "date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateHistogramAggregation?)value.Variant); + break; + case "date_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DateRangeAggregation?)value.Variant); + break; + case "derivative": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DerivativeAggregation?)value.Variant); + break; + case "diversified_sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.DiversifiedSamplerAggregation?)value.Variant); + break; + case "extended_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsAggregation?)value.Variant); + break; + case "extended_stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedStatsBucketAggregation?)value.Variant); + break; + case "filter": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query?)value.Variant); + break; + case "filters": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FiltersAggregation?)value.Variant); + break; + case "frequent_item_sets": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.FrequentItemSetsAggregation?)value.Variant); + break; + case "geo_bounds": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoBoundsAggregation?)value.Variant); + break; + case "geo_centroid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoCentroidAggregation?)value.Variant); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoDistanceAggregation?)value.Variant); + break; + case "geohash_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohashGridAggregation?)value.Variant); + break; + case "geohex_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeohexGridAggregation?)value.Variant); + break; + case "geo_line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation?)value.Variant); + break; + case "geotile_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeotileGridAggregation?)value.Variant); + break; + case "global": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GlobalAggregation?)value.Variant); + break; + case "histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.HistogramAggregation?)value.Variant); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.InferenceAggregation?)value.Variant); + break; + case "ip_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpPrefixAggregation?)value.Variant); + break; + case "ip_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.IpRangeAggregation?)value.Variant); + break; + case "line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.GeoLineAggregation?)value.Variant); + break; + case "matrix_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MatrixStatsAggregation?)value.Variant); + break; + case "max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxAggregation?)value.Variant); + break; + case "max_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MaxBucketAggregation?)value.Variant); + break; + case "median_absolute_deviation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MedianAbsoluteDeviationAggregation?)value.Variant); + break; + case "min": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinAggregation?)value.Variant); + break; + case "min_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MinBucketAggregation?)value.Variant); + break; + case "missing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingAggregation?)value.Variant); + break; + case "moving_fn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingFunctionAggregation?)value.Variant); + break; + case "moving_percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MovingPercentilesAggregation?)value.Variant); + break; + case "multi_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.MultiTermsAggregation?)value.Variant); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NestedAggregation?)value.Variant); + break; + case "normalize": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.NormalizeAggregation?)value.Variant); + break; + case "parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ParentAggregation?)value.Variant); + break; + case "percentile_ranks": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentileRanksAggregation?)value.Variant); + break; + case "percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesAggregation?)value.Variant); + break; + case "percentiles_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentilesBucketAggregation?)value.Variant); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RangeAggregation?)value.Variant); + break; + case "rare_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RareTermsAggregation?)value.Variant); + break; + case "rate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.RateAggregation?)value.Variant); + break; + case "reverse_nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ReverseNestedAggregation?)value.Variant); + break; + case "sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SamplerAggregation?)value.Variant); + break; + case "scripted_metric": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedMetricAggregation?)value.Variant); + break; + case "serial_diff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SerialDifferencingAggregation?)value.Variant); + break; + case "significant_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTermsAggregation?)value.Variant); + break; + case "significant_text": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SignificantTextAggregation?)value.Variant); + break; + case "stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsAggregation?)value.Variant); + break; + case "stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StatsBucketAggregation?)value.Variant); + break; + case "string_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.StringStatsAggregation?)value.Variant); + break; + case "sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumAggregation?)value.Variant); + break; + case "sum_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.SumBucketAggregation?)value.Variant); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregation?)value.Variant); + break; + case "top_hits": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopHitsAggregation?)value.Variant); + break; + case "top_metrics": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsAggregation?)value.Variant); + break; + case "t_test": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.TTestAggregation?)value.Variant); + break; + case "value_count": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.ValueCountAggregation?)value.Variant); + break; + case "variable_width_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.VariableWidthHistogramAggregation?)value.Variant); + break; + case "weighted_avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Aggregations.WeightedAverageAggregation?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Aggregation)}'."); } + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropMeta, value.Meta); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs index 7e74900acda..e5a494ee7fc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class AutoDateHistogramAggregate : IAggregate public string Interval { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "auto_date_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AverageAggregate.g.cs index c583ff496b8..c52314f371c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/AverageAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class AverageAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "avg"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BoxplotAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BoxplotAggregate.g.cs index 2be67ea4c19..ec37622f85c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BoxplotAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BoxplotAggregate.g.cs @@ -59,4 +59,6 @@ public sealed partial class BoxplotAggregate : IAggregate public double Upper { get; init; } [JsonInclude, JsonPropertyName("upper_as_string")] public string? UpperAsString { get; init; } + + string IAggregate.Type => "boxplot"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs index 4929e00d636..31def6d1b8a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs @@ -44,4 +44,6 @@ public sealed partial class BucketMetricValueAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "bucket_metric_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketSortAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketSortAggregation.g.cs index 93e5a1a5b67..c308c3e9f9b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketSortAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/BucketSortAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class BucketSortAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropGapPolicy = System.Text.Json.JsonEncodedText.Encode("gap_policy"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override BucketSortAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFrom = default; + LocalJsonProperty propGapPolicy = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propGapPolicy.TryRead(ref reader, options, PropGapPolicy)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BucketSortAggregation + { + From = propFrom.Value +, + GapPolicy = propGapPolicy.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BucketSortAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropGapPolicy, value.GapPolicy); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BucketSortAggregationConverter))] public sealed partial class BucketSortAggregation { /// @@ -34,7 +99,6 @@ public sealed partial class BucketSortAggregation /// Buckets in positions prior to from will be truncated. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -42,7 +106,6 @@ public sealed partial class BucketSortAggregation /// The policy to apply when gaps are found in the data. /// /// - [JsonInclude, JsonPropertyName("gap_policy")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GapPolicy? GapPolicy { get; set; } /// @@ -51,7 +114,6 @@ public sealed partial class BucketSortAggregation /// Defaults to all buckets of the parent aggregation. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -59,8 +121,6 @@ public sealed partial class BucketSortAggregation /// The list of fields to sort on. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(BucketSortAggregation bucketSortAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.BucketSort(bucketSortAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CardinalityAggregate.g.cs index f6c9cc9a95a..bb70e7d2d43 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CardinalityAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class CardinalityAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("value")] public long Value { get; init; } + + string IAggregate.Type => "cardinality"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ChildrenAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ChildrenAggregate.g.cs index cb007f3ba2d..a73993380b7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ChildrenAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ChildrenAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class ChildrenAggregateConverter : JsonConverter +internal sealed partial class ChildrenAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ChildrenAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ChildrenAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ChildrenAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChildrenAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ChildrenAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChildrenAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ChildrenAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class ChildrenAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "children"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeAggregate.g.cs index 29704ff5e9b..5019c2c5b1c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class CompositeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "composite"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeBucket.g.cs index 22f264dd557..b8bf9e0bca0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CompositeBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class CompositeBucketConverter : JsonConverter +internal sealed partial class CompositeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override CompositeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override CompositeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new CompositeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompositeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, CompositeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompositeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'CompositeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs index c0a86ffc1cd..b45677dbc2c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs @@ -40,4 +40,6 @@ public sealed partial class CumulativeCardinalityAggregate : IAggregate public long Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "simple_long_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs index 6a9e78363d8..3258ea6df5f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class DateHistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "date_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs index 5abfd93f60d..2b291664d8c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,160 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class DateHistogramAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarInterval = System.Text.Json.JsonEncodedText.Encode("calendar_interval"); + private static readonly System.Text.Json.JsonEncodedText PropExtendedBounds = System.Text.Json.JsonEncodedText.Encode("extended_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFixedInterval = System.Text.Json.JsonEncodedText.Encode("fixed_interval"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropHardBounds = System.Text.Json.JsonEncodedText.Encode("hard_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropParams = System.Text.Json.JsonEncodedText.Encode("params"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override DateHistogramAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCalendarInterval = default; + LocalJsonProperty propExtendedBounds = default; + LocalJsonProperty propField = default; + LocalJsonProperty propFixedInterval = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propHardBounds = default; + LocalJsonProperty propMinDocCount = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty>?> propOrder = default; + LocalJsonProperty?> propParams = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarInterval.TryRead(ref reader, options, PropCalendarInterval)) + { + continue; + } + + if (propExtendedBounds.TryRead(ref reader, options, PropExtendedBounds)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFixedInterval.TryRead(ref reader, options, PropFixedInterval)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propHardBounds.TryRead(ref reader, options, PropHardBounds)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propParams.TryRead(ref reader, options, PropParams)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateHistogramAggregation + { + CalendarInterval = propCalendarInterval.Value +, + ExtendedBounds = propExtendedBounds.Value +, + Field = propField.Value +, + FixedInterval = propFixedInterval.Value +, + Format = propFormat.Value +, + HardBounds = propHardBounds.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + Offset = propOffset.Value +, + Order = propOrder.Value +, + Params = propParams.Value +, + Script = propScript.Value +, + TimeZone = propTimeZone.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateHistogramAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarInterval, value.CalendarInterval); + writer.WriteProperty(options, PropExtendedBounds, value.ExtendedBounds); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFixedInterval, value.FixedInterval); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropHardBounds, value.HardBounds); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOrder, value.Order, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropParams, value.Params); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateHistogramAggregationConverter))] public sealed partial class DateHistogramAggregation { /// @@ -35,7 +190,6 @@ public sealed partial class DateHistogramAggregation /// Can be specified using the unit name, such as month, or as a single unit quantity, such as 1M. /// /// - [JsonInclude, JsonPropertyName("calendar_interval")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.CalendarInterval? CalendarInterval { get; set; } /// @@ -43,7 +197,6 @@ public sealed partial class DateHistogramAggregation /// Enables extending the bounds of the histogram beyond the data itself. /// /// - [JsonInclude, JsonPropertyName("extended_bounds")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? ExtendedBounds { get; set; } /// @@ -51,7 +204,6 @@ public sealed partial class DateHistogramAggregation /// The date field whose values are use to build a histogram. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } /// @@ -59,7 +211,6 @@ public sealed partial class DateHistogramAggregation /// Fixed intervals: a fixed number of SI units and never deviate, regardless of where they fall on the calendar. /// /// - [JsonInclude, JsonPropertyName("fixed_interval")] public Elastic.Clients.Elasticsearch.Serverless.Duration? FixedInterval { get; set; } /// @@ -68,7 +219,6 @@ public sealed partial class DateHistogramAggregation /// If no format is specified, the first date format specified in the field mapping is used. /// /// - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -76,7 +226,6 @@ public sealed partial class DateHistogramAggregation /// Limits the histogram to specified bounds. /// /// - [JsonInclude, JsonPropertyName("hard_bounds")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsDate? HardBounds { get; set; } /// @@ -85,7 +234,6 @@ public sealed partial class DateHistogramAggregation /// By default, all buckets between the first bucket that matches documents and the last one are returned. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -94,7 +242,6 @@ public sealed partial class DateHistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public DateTimeOffset? Missing { get; set; } /// @@ -102,7 +249,6 @@ public sealed partial class DateHistogramAggregation /// Changes the start value of each bucket by the specified positive (+) or negative offset (-) duration. /// /// - [JsonInclude, JsonPropertyName("offset")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Offset { get; set; } /// @@ -110,12 +256,8 @@ public sealed partial class DateHistogramAggregation /// The sort order of the returned buckets. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("params")] public IDictionary? Params { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } /// @@ -124,7 +266,6 @@ public sealed partial class DateHistogramAggregation /// Defaults to Coordinated Universal Time (UTC). /// /// - [JsonInclude, JsonPropertyName("time_zone")] public string? TimeZone { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(DateHistogramAggregation dateHistogramAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.DateHistogram(dateHistogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramBucket.g.cs index 26386f3c977..d61b1de8d97 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateHistogramBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,56 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class DateHistogramBucketConverter : JsonConverter +internal sealed partial class DateHistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override DateHistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override DateHistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DateHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateHistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, DateHistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateHistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DateHistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateRangeAggregate.g.cs index a885c04604d..4ed7beed321 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DateRangeAggregate.g.cs @@ -39,4 +39,6 @@ public sealed partial class DateRangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "date_range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DerivativeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DerivativeAggregate.g.cs index d5399747ce3..3a649cca7a3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DerivativeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DerivativeAggregate.g.cs @@ -46,4 +46,6 @@ public sealed partial class DerivativeAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "derivative"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs index 10bb23a1570..9cae153cfe2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class DoubleTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "dterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs index 5dc845c246a..e520c8bdb86 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,63 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class DoubleTermsBucketConverter : JsonConverter +internal sealed partial class DoubleTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override DoubleTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override DoubleTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - double key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propDocCountErrorUpperBound = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DoubleTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, DoubleTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DoubleTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs index fedb4c95f79..ce1ce75021d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs @@ -77,4 +77,6 @@ public sealed partial class ExtendedStatsAggregate : IAggregate public double? VarianceSampling { get; init; } [JsonInclude, JsonPropertyName("variance_sampling_as_string")] public string? VarianceSamplingAsString { get; init; } + + string IAggregate.Type => "extended_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs index 2d1e56afb66..4d351f70d71 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs @@ -77,4 +77,6 @@ public sealed partial class ExtendedStatsBucketAggregate : IAggregate public double? VarianceSampling { get; init; } [JsonInclude, JsonPropertyName("variance_sampling_as_string")] public string? VarianceSamplingAsString { get; init; } + + string IAggregate.Type => "extended_stats_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FilterAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FilterAggregate.g.cs index 1518ef244d1..192a877df58 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FilterAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FilterAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class FilterAggregateConverter : JsonConverter +internal sealed partial class FilterAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override FilterAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override FilterAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FilterAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FilterAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, FilterAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FilterAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FilterAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class FilterAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "filter"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersAggregate.g.cs index a830d0c0c65..bcd8e5383e4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class FiltersAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "filters"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersBucket.g.cs index 0de13876564..f0f8a467e62 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FiltersBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,42 +28,50 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class FiltersBucketConverter : JsonConverter +internal sealed partial class FiltersBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override FiltersBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + + public override FiltersBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FiltersBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FiltersBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value + }; } - public override void Write(Utf8JsonWriter writer, FiltersBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FiltersBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FiltersBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs index 10327902268..77f6ef424e2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class FrequentItemSetsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "frequent_item_sets"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs index 61749981144..7713d42906f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,56 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class FrequentItemSetsBucketConverter : JsonConverter +internal sealed partial class FrequentItemSetsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override FrequentItemSetsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropSupport = System.Text.Json.JsonEncodedText.Encode("support"); + + public override FrequentItemSetsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary> key = default; - double support = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty>> propKey = default; + LocalJsonProperty propSupport = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>>(ref reader, options); - continue; - } - - if (property == "support") - { - support = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propSupport.TryRead(ref reader, options, PropSupport)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FrequentItemSetsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, Support = support }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FrequentItemSetsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + Support = propSupport.Value + }; } - public override void Write(Utf8JsonWriter writer, FrequentItemSetsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FrequentItemSetsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FrequentItemSetsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropSupport, value.Support); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs index 45bdf6b6fa1..e53ba7e48c0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeoBoundsAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.GeoBounds? Bounds { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_bounds"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs index 2743788a100..9822229deca 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class GeoCentroidAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.GeoLocation? Location { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_centroid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs index df2c4d5c0ba..cbe77a3f826 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class GeoDistanceAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_distance"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoLineAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoLineAggregate.g.cs index b2072a2fefa..8939b87c8aa 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoLineAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeoLineAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class GeoLineAggregate : IAggregate public object Properties { get; init; } [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } + + string IAggregate.Type => "geo_line"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs index 3480803eef0..fd67b6e4fd8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeohashGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geohash_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridBucket.g.cs index 1bb531d814f..36e18867729 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohashGridBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class GeohashGridBucketConverter : JsonConverter +internal sealed partial class GeohashGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeohashGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeohashGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohashGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohashGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeohashGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeohashGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeohashGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs index 1667939d82a..6c5668663cd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeohexGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geohex_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridBucket.g.cs index 5878ecf1f79..ad1efd611e3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeohexGridBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class GeohexGridBucketConverter : JsonConverter +internal sealed partial class GeohexGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeohexGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeohexGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohexGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohexGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeohexGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeohexGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeohexGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs index 8e6cb1d6d12..c3de1563c32 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeotileGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geotile_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridBucket.g.cs index cfcaeda800e..28d0379ca49 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GeotileGridBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class GeotileGridBucketConverter : JsonConverter +internal sealed partial class GeotileGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeotileGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeotileGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeotileGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeotileGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeotileGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeotileGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeotileGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GlobalAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GlobalAggregate.g.cs index d20cbd31f1c..a3cdab2f58c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GlobalAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/GlobalAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class GlobalAggregateConverter : JsonConverter +internal sealed partial class GlobalAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override GlobalAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override GlobalAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GlobalAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GlobalAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, GlobalAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GlobalAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GlobalAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class GlobalAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "global"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs index 6cc5bdc26df..03221158d13 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HdrPercentileRanksAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs index 5da78134c81..f177f279d1c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HdrPercentilesAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregate.g.cs index ca1937cb8c6..432000bd4ba 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregation.g.cs index 35865ac046e..e2a5ff8bf37 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,130 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class HistogramAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropExtendedBounds = System.Text.Json.JsonEncodedText.Encode("extended_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropHardBounds = System.Text.Json.JsonEncodedText.Encode("hard_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropInterval = System.Text.Json.JsonEncodedText.Encode("interval"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override HistogramAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propExtendedBounds = default; + LocalJsonProperty propField = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propHardBounds = default; + LocalJsonProperty propInterval = default; + LocalJsonProperty propMinDocCount = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty>?> propOrder = default; + LocalJsonProperty propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExtendedBounds.TryRead(ref reader, options, PropExtendedBounds)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propHardBounds.TryRead(ref reader, options, PropHardBounds)) + { + continue; + } + + if (propInterval.TryRead(ref reader, options, PropInterval)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramAggregation + { + ExtendedBounds = propExtendedBounds.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + HardBounds = propHardBounds.Value +, + Interval = propInterval.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + Offset = propOffset.Value +, + Order = propOrder.Value +, + Script = propScript.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExtendedBounds, value.ExtendedBounds); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropHardBounds, value.HardBounds); + writer.WriteProperty(options, PropInterval, value.Interval); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOrder, value.Order, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HistogramAggregationConverter))] public sealed partial class HistogramAggregation { /// @@ -34,7 +159,6 @@ public sealed partial class HistogramAggregation /// Enables extending the bounds of the histogram beyond the data itself. /// /// - [JsonInclude, JsonPropertyName("extended_bounds")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsFloat? ExtendedBounds { get; set; } /// @@ -42,9 +166,7 @@ public sealed partial class HistogramAggregation /// The name of the field to aggregate on. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -53,7 +175,6 @@ public sealed partial class HistogramAggregation /// It is particularly useful in the case of open data ranges that can result in a very large number of buckets. /// /// - [JsonInclude, JsonPropertyName("hard_bounds")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ExtendedBoundsFloat? HardBounds { get; set; } /// @@ -62,7 +183,6 @@ public sealed partial class HistogramAggregation /// Must be a positive decimal. /// /// - [JsonInclude, JsonPropertyName("interval")] public double? Interval { get; set; } /// @@ -71,7 +191,6 @@ public sealed partial class HistogramAggregation /// By default, the response will fill gaps in the histogram with empty buckets. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -80,7 +199,6 @@ public sealed partial class HistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public double? Missing { get; set; } /// @@ -89,7 +207,6 @@ public sealed partial class HistogramAggregation /// The bucket boundaries can be shifted by using the offset option. /// /// - [JsonInclude, JsonPropertyName("offset")] public double? Offset { get; set; } /// @@ -98,10 +215,7 @@ public sealed partial class HistogramAggregation /// By default, the returned buckets are sorted by their key ascending. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(HistogramAggregation histogramAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.Histogram(histogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramBucket.g.cs index fe02969739e..6409b1f3072 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/HistogramBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,56 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class HistogramBucketConverter : JsonConverter +internal sealed partial class HistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override HistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override HistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new HistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, HistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'HistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceAggregate.g.cs index c181704ab19..c3ed0f75539 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,65 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class InferenceAggregateConverter : JsonConverter +internal sealed partial class InferenceAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureImportance = System.Text.Json.JsonEncodedText.Encode("feature_importance"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropTopClasses = System.Text.Json.JsonEncodedText.Encode("top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + private static readonly System.Text.Json.JsonEncodedText PropWarning = System.Text.Json.JsonEncodedText.Encode("warning"); + + public override InferenceAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection? featureImportance = default; - IReadOnlyDictionary? meta = default; - IReadOnlyCollection? topClasses = default; - Elastic.Clients.Elasticsearch.Serverless.FieldValue? value = default; - string? warning = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propData = default; + LocalJsonProperty?> propFeatureImportance = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty?> propTopClasses = default; + LocalJsonProperty propValue = default; + LocalJsonProperty propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFeatureImportance.TryRead(ref reader, options, PropFeatureImportance)) { - var property = reader.GetString(); - if (property == "feature_importance") - { - featureImportance = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; + } - if (property == "top_classes") - { - topClasses = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } - if (property == "value") - { - value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propTopClasses.TryRead(ref reader, options, PropTopClasses)) + { + continue; + } - if (property == "warning") - { - warning = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propWarning.TryRead(ref reader, options, PropWarning)) + { + continue; } + + propData ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propData[key] = value; } - return new InferenceAggregate { Data = additionalProperties, FeatureImportance = featureImportance, Meta = meta, TopClasses = topClasses, Value = value, Warning = warning }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceAggregate + { + Data = propData +, + FeatureImportance = propFeatureImportance.Value +, + Meta = propMeta.Value +, + TopClasses = propTopClasses.Value +, + Value = propValue.Value +, + Warning = propWarning.Value + }; } - public override void Write(Utf8JsonWriter writer, InferenceAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'InferenceAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureImportance, value.FeatureImportance); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropTopClasses, value.TopClasses); + writer.WriteProperty(options, PropValue, value.Value); + writer.WriteProperty(options, PropWarning, value.Warning); + if (value.Data is not null) + { + foreach (var item in value.Data) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -103,4 +129,6 @@ public sealed partial class InferenceAggregate : IAggregate public IReadOnlyCollection? TopClasses { get; init; } public Elastic.Clients.Elasticsearch.Serverless.FieldValue? Value { get; init; } public string? Warning { get; init; } + + string IAggregate.Type => "inference"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceConfig.g.cs index e0656593355..e49f5cddb32 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/InferenceConfig.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal InferenceConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfig Classification(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfig("classification", classificationInferenceOptions); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions regressionInferenceOptions) => new InferenceConfig("regression", regressionInferenceOptions); @@ -62,67 +67,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigConverter : JsonConverter +internal sealed partial class InferenceConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override InferenceConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs index e5cc36e2271..99864e08720 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class IpPrefixAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "ip_prefix"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixBucket.g.cs index 8ad90a71f6b..b0bcd9a5428 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpPrefixBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,70 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class IpPrefixBucketConverter : JsonConverter +internal sealed partial class IpPrefixBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override IpPrefixBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropIsIpv6 = System.Text.Json.JsonEncodedText.Encode("is_ipv6"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropNetmask = System.Text.Json.JsonEncodedText.Encode("netmask"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + + public override IpPrefixBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - bool isIpv6 = default; - string key = default; - string? netmask = default; - int prefixLength = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propIsIpv6 = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propNetmask = default; + LocalJsonProperty propPrefixLength = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "is_ipv6") - { - isIpv6 = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "netmask") - { - netmask = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propIsIpv6.TryRead(ref reader, options, PropIsIpv6)) + { + continue; + } - if (property == "prefix_length") - { - prefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propNetmask.TryRead(ref reader, options, PropNetmask)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpPrefixBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, IsIpv6 = isIpv6, Key = key, Netmask = netmask, PrefixLength = prefixLength }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpPrefixBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + IsIpv6 = propIsIpv6.Value +, + Key = propKey.Value +, + Netmask = propNetmask.Value +, + PrefixLength = propPrefixLength.Value + }; } - public override void Write(Utf8JsonWriter writer, IpPrefixBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpPrefixBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'IpPrefixBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropIsIpv6, value.IsIpv6); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropNetmask, value.Netmask); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeAggregate.g.cs index 93fe5cb476e..0457c897615 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class IpRangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "ip_range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeBucket.g.cs index eb63a544bb6..ee26248766a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/IpRangeBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,63 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class IpRangeBucketConverter : JsonConverter +internal sealed partial class IpRangeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override IpRangeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropTo = System.Text.Json.JsonEncodedText.Encode("to"); + + public override IpRangeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string? from = default; - string? key = default; - string? to = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propTo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from") - { - from = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "to") - { - to = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propTo.TryRead(ref reader, options, PropTo)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpRangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, From = from, Key = key, To = to }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpRangeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + From = propFrom.Value +, + Key = propKey.Value +, + To = propTo.Value + }; } - public override void Write(Utf8JsonWriter writer, IpRangeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpRangeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'IpRangeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropTo, value.To); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs index f609bb3999b..1d2865b217a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class LongRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "lrareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs index 97f7fb82c59..2b0c3fc2465 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,56 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class LongRareTermsBucketConverter : JsonConverter +internal sealed partial class LongRareTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override LongRareTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override LongRareTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, LongRareTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongRareTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'LongRareTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsAggregate.g.cs index b4bfc3acf8f..0d14e75adbf 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class LongTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "lterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsBucket.g.cs index 6d3ebf56606..88bb02a96eb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/LongTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,63 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class LongTermsBucketConverter : JsonConverter +internal sealed partial class LongTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override LongTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override LongTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propDocCountErrorUpperBound = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, LongTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'LongTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs index 04992647c72..28c5b63e133 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class MatrixStatsAggregate : IAggregate public IReadOnlyCollection? Fields { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "matrix_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs index dd596d44720..b329200cb48 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class MatrixStatsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + + public override MatrixStatsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFields = default; + LocalJsonProperty?> propMissing = default; + LocalJsonProperty propMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatrixStatsAggregation + { + Fields = propFields.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatrixStatsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MatrixStatsAggregationConverter))] public sealed partial class MatrixStatsAggregation { /// @@ -34,8 +89,6 @@ public sealed partial class MatrixStatsAggregation /// An array of fields for computing the statistics. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -44,7 +97,6 @@ public sealed partial class MatrixStatsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public IDictionary? Missing { get; set; } /// @@ -52,7 +104,6 @@ public sealed partial class MatrixStatsAggregation /// Array value the aggregation will use for array or multi-valued fields. /// /// - [JsonInclude, JsonPropertyName("mode")] public Elastic.Clients.Elasticsearch.Serverless.SortMode? Mode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(MatrixStatsAggregation matrixStatsAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.MatrixStats(matrixStatsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsFields.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsFields.g.cs index 7938ea4a34d..961a1d8f0d7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MatrixStatsFields.g.cs @@ -30,12 +30,10 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; public sealed partial class MatrixStatsFields { [JsonInclude, JsonPropertyName("correlation")] - [ReadOnlyFieldDictionaryConverter(typeof(double))] public IReadOnlyDictionary Correlation { get; init; } [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } [JsonInclude, JsonPropertyName("covariance")] - [ReadOnlyFieldDictionaryConverter(typeof(double))] public IReadOnlyDictionary Covariance { get; init; } [JsonInclude, JsonPropertyName("kurtosis")] public double Kurtosis { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MaxAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MaxAggregate.g.cs index a17cee15fdd..af01aec9a0d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MaxAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MaxAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MaxAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "max"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs index 572d8d27a3a..35fd9b078ac 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MedianAbsoluteDeviationAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "median_absolute_deviation"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MinAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MinAggregate.g.cs index c027bc24cfb..482da34a69a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MinAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MinAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MinAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "min"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MissingAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MissingAggregate.g.cs index 7beb0b402f8..4a21bbafe83 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MissingAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MissingAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class MissingAggregateConverter : JsonConverter +internal sealed partial class MissingAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override MissingAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override MissingAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MissingAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MissingAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, MissingAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MissingAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'MissingAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class MissingAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "missing"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs index 2cbb83d7203..371a0ab210a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class MultiTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "multi_terms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs index 385bae8dd19..ef1ded8da89 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class MultiTermsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollectMode = System.Text.Json.JsonEncodedText.Encode("collect_mode"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropShowTermDocCountError = System.Text.Json.JsonEncodedText.Encode("show_term_doc_count_error"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override MultiTermsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCollectMode = default; + LocalJsonProperty propMinDocCount = default; + LocalJsonProperty>?> propOrder = default; + LocalJsonProperty propShardMinDocCount = default; + LocalJsonProperty propShardSize = default; + LocalJsonProperty propShowTermDocCountError = default; + LocalJsonProperty propSize = default; + LocalJsonProperty> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryRead(ref reader, options, PropCollectMode)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propShowTermDocCountError.TryRead(ref reader, options, PropShowTermDocCountError)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermsAggregation + { + CollectMode = propCollectMode.Value +, + MinDocCount = propMinDocCount.Value +, + Order = propOrder.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + ShowTermDocCountError = propShowTermDocCountError.Value +, + Size = propSize.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollectMode, value.CollectMode); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropOrder, value.Order, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropTerms, value.Terms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermsAggregationConverter))] public sealed partial class MultiTermsAggregation { /// @@ -34,7 +139,6 @@ public sealed partial class MultiTermsAggregation /// Specifies the strategy for data collection. /// /// - [JsonInclude, JsonPropertyName("collect_mode")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -42,7 +146,6 @@ public sealed partial class MultiTermsAggregation /// The minimum number of documents in a bucket for it to be returned. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public long? MinDocCount { get; set; } /// @@ -51,8 +154,6 @@ public sealed partial class MultiTermsAggregation /// Defaults to sorting by descending document count. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } /// @@ -60,7 +161,6 @@ public sealed partial class MultiTermsAggregation /// The minimum number of documents in a bucket on each shard for it to be returned. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -69,7 +169,6 @@ public sealed partial class MultiTermsAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -77,7 +176,6 @@ public sealed partial class MultiTermsAggregation /// Calculates the doc count error on per term basis. /// /// - [JsonInclude, JsonPropertyName("show_term_doc_count_error")] public bool? ShowTermDocCountError { get; set; } /// @@ -85,7 +183,6 @@ public sealed partial class MultiTermsAggregation /// The number of term buckets should be returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -93,7 +190,6 @@ public sealed partial class MultiTermsAggregation /// The field from which to generate sets of terms. /// /// - [JsonInclude, JsonPropertyName("terms")] public ICollection Terms { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(MultiTermsAggregation multiTermsAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.MultiTerms(multiTermsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsBucket.g.cs index 8ffc914e5ea..17b57856fae 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/MultiTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,63 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class MultiTermsBucketConverter : JsonConverter +internal sealed partial class MultiTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override MultiTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override MultiTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - IReadOnlyCollection key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propDocCountErrorUpperBound = default; + LocalJsonProperty> propKey = default; + LocalJsonProperty propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MultiTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, MultiTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'MultiTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/NestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/NestedAggregate.g.cs index 2fecd1dea37..6d792beb5d5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/NestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/NestedAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class NestedAggregateConverter : JsonConverter +internal sealed partial class NestedAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override NestedAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override NestedAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new NestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, NestedAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NestedAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NestedAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class NestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "nested"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ParentAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ParentAggregate.g.cs index c504491ea66..5db48ce90ee 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ParentAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ParentAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class ParentAggregateConverter : JsonConverter +internal sealed partial class ParentAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ParentAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ParentAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ParentAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ParentAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ParentAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ParentAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ParentAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class ParentAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "parent"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs index e29d1a9a062..c991e237457 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class PercentilesBucketAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "percentiles_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeAggregate.g.cs index b27d6bb4052..5b1487aeb21 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class RangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeBucket.g.cs index 92d28d6da79..9022a5a047c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RangeBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,77 +28,100 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class RangeBucketConverter : JsonConverter +internal sealed partial class RangeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override RangeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropFromAsString = System.Text.Json.JsonEncodedText.Encode("from_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropTo = System.Text.Json.JsonEncodedText.Encode("to"); + private static readonly System.Text.Json.JsonEncodedText PropToAsString = System.Text.Json.JsonEncodedText.Encode("to_as_string"); + + public override RangeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double? from = default; - string? fromAsString = default; - string? key = default; - double? to = default; - string? toAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propFromAsString = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propTo = default; + LocalJsonProperty propToAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propFromAsString.TryRead(ref reader, options, PropFromAsString)) + { + continue; + } + + if (propKey.TryRead(ref reader, options, PropKey)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from") - { - from = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from_as_string") - { - fromAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "to") - { - to = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "to_as_string") - { - toAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + if (propTo.TryRead(ref reader, options, PropTo)) + { + continue; + } + + if (propToAsString.TryRead(ref reader, options, PropToAsString)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new RangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, From = from, FromAsString = fromAsString, Key = key, To = to, ToAsString = toAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RangeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + From = propFrom.Value +, + FromAsString = propFromAsString.Value +, + Key = propKey.Value +, + To = propTo.Value +, + ToAsString = propToAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, RangeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RangeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'RangeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropFromAsString, value.FromAsString); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropTo, value.To); + writer.WriteProperty(options, PropToAsString, value.ToAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RateAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RateAggregate.g.cs index 303bfe634f3..d0aaf95fda9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RateAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/RateAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class RateAggregate : IAggregate public double Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "rate"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs index b4dcfa21b23..733b3ec4ef1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class ReverseNestedAggregateConverter : JsonConverter +internal sealed partial class ReverseNestedAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ReverseNestedAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ReverseNestedAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ReverseNestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReverseNestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ReverseNestedAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReverseNestedAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ReverseNestedAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class ReverseNestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "reverse_nested"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SamplerAggregate.g.cs index f067ef6d31b..286b733c826 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SamplerAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class SamplerAggregateConverter : JsonConverter +internal sealed partial class SamplerAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override SamplerAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override SamplerAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, SamplerAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamplerAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SamplerAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class SamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "sampler"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs index 51ddfb89dc8..7e9a7886782 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class ScriptedMetricAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("value")] public object Value { get; init; } + + string IAggregate.Type => "scripted_metric"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs index 682a7e49a9e..fab068197a5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class SignificantLongTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "siglterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs index b2e0622e3b8..cd28f56e73b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,70 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class SignificantLongTermsBucketConverter : JsonConverter +internal sealed partial class SignificantLongTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override SignificantLongTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropBgCount = System.Text.Json.JsonEncodedText.Encode("bg_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override SignificantLongTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long bgCount = default; - long docCount = default; - long key = default; - string? keyAsString = default; - double score = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propBgCount = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + LocalJsonProperty propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryRead(ref reader, options, PropBgCount)) { - var property = reader.GetString(); - if (property == "bg_count") - { - bgCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } - if (property == "score") - { - score = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantLongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), BgCount = bgCount, DocCount = docCount, Key = key, KeyAsString = keyAsString, Score = score }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantLongTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + BgCount = propBgCount.Value +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value +, + Score = propScore.Value + }; } - public override void Write(Utf8JsonWriter writer, SignificantLongTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantLongTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SignificantLongTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBgCount, value.BgCount); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + writer.WriteProperty(options, PropScore, value.Score); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs index 636834cdfd1..631c71aa373 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class SignificantStringTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "sigsterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs index 4adf4ae4fc4..ce51892965b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,63 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class SignificantStringTermsBucketConverter : JsonConverter +internal sealed partial class SignificantStringTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override SignificantStringTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropBgCount = System.Text.Json.JsonEncodedText.Encode("bg_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override SignificantStringTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long bgCount = default; - long docCount = default; - string key = default; - double score = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propBgCount = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryRead(ref reader, options, PropBgCount)) { - var property = reader.GetString(); - if (property == "bg_count") - { - bgCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "score") - { - score = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantStringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), BgCount = bgCount, DocCount = docCount, Key = key, Score = score }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantStringTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + BgCount = propBgCount.Value +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + Score = propScore.Value + }; } - public override void Write(Utf8JsonWriter writer, SignificantStringTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantStringTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SignificantStringTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBgCount, value.BgCount); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropScore, value.Score); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs index 3b445cbbdda..a530f0131ea 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,200 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class SignificantTextAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackgroundFilter = System.Text.Json.JsonEncodedText.Encode("background_filter"); + private static readonly System.Text.Json.JsonEncodedText PropChiSquare = System.Text.Json.JsonEncodedText.Encode("chi_square"); + private static readonly System.Text.Json.JsonEncodedText PropExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropExecutionHint = System.Text.Json.JsonEncodedText.Encode("execution_hint"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilterDuplicateText = System.Text.Json.JsonEncodedText.Encode("filter_duplicate_text"); + private static readonly System.Text.Json.JsonEncodedText PropGnd = System.Text.Json.JsonEncodedText.Encode("gnd"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropJlh = System.Text.Json.JsonEncodedText.Encode("jlh"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMutualInformation = System.Text.Json.JsonEncodedText.Encode("mutual_information"); + private static readonly System.Text.Json.JsonEncodedText PropPercentage = System.Text.Json.JsonEncodedText.Encode("percentage"); + private static readonly System.Text.Json.JsonEncodedText PropScriptHeuristic = System.Text.Json.JsonEncodedText.Encode("script_heuristic"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSourceFields = System.Text.Json.JsonEncodedText.Encode("source_fields"); + + public override SignificantTextAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBackgroundFilter = default; + LocalJsonProperty propChiSquare = default; + LocalJsonProperty propExclude = default; + LocalJsonProperty propExecutionHint = default; + LocalJsonProperty propField = default; + LocalJsonProperty propFilterDuplicateText = default; + LocalJsonProperty propGnd = default; + LocalJsonProperty propInclude = default; + LocalJsonProperty propJlh = default; + LocalJsonProperty propMinDocCount = default; + LocalJsonProperty propMutualInformation = default; + LocalJsonProperty propPercentage = default; + LocalJsonProperty propScriptHeuristic = default; + LocalJsonProperty propShardMinDocCount = default; + LocalJsonProperty propShardSize = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackgroundFilter.TryRead(ref reader, options, PropBackgroundFilter)) + { + continue; + } + + if (propChiSquare.TryRead(ref reader, options, PropChiSquare)) + { + continue; + } + + if (propExclude.TryRead(ref reader, options, PropExclude)) + { + continue; + } + + if (propExecutionHint.TryRead(ref reader, options, PropExecutionHint)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilterDuplicateText.TryRead(ref reader, options, PropFilterDuplicateText)) + { + continue; + } + + if (propGnd.TryRead(ref reader, options, PropGnd)) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propJlh.TryRead(ref reader, options, PropJlh)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMutualInformation.TryRead(ref reader, options, PropMutualInformation)) + { + continue; + } + + if (propPercentage.TryRead(ref reader, options, PropPercentage)) + { + continue; + } + + if (propScriptHeuristic.TryRead(ref reader, options, PropScriptHeuristic)) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSourceFields.TryRead(ref reader, options, PropSourceFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantTextAggregation + { + BackgroundFilter = propBackgroundFilter.Value +, + ChiSquare = propChiSquare.Value +, + Exclude = propExclude.Value +, + ExecutionHint = propExecutionHint.Value +, + Field = propField.Value +, + FilterDuplicateText = propFilterDuplicateText.Value +, + Gnd = propGnd.Value +, + Include = propInclude.Value +, + Jlh = propJlh.Value +, + MinDocCount = propMinDocCount.Value +, + MutualInformation = propMutualInformation.Value +, + Percentage = propPercentage.Value +, + ScriptHeuristic = propScriptHeuristic.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + Size = propSize.Value +, + SourceFields = propSourceFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantTextAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackgroundFilter, value.BackgroundFilter); + writer.WriteProperty(options, PropChiSquare, value.ChiSquare); + writer.WriteProperty(options, PropExclude, value.Exclude); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilterDuplicateText, value.FilterDuplicateText); + writer.WriteProperty(options, PropGnd, value.Gnd); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropJlh, value.Jlh); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMutualInformation, value.MutualInformation); + writer.WriteProperty(options, PropPercentage, value.Percentage); + writer.WriteProperty(options, PropScriptHeuristic, value.ScriptHeuristic); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SignificantTextAggregationConverter))] public sealed partial class SignificantTextAggregation { /// @@ -34,7 +229,6 @@ public sealed partial class SignificantTextAggregation /// A background filter that can be used to focus in on significant terms within a narrower context, instead of the entire index. /// /// - [JsonInclude, JsonPropertyName("background_filter")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? BackgroundFilter { get; set; } /// @@ -42,7 +236,6 @@ public sealed partial class SignificantTextAggregation /// Use Chi square, as described in "Information Retrieval", Manning et al., Chapter 13.5.2, as the significance score. /// /// - [JsonInclude, JsonPropertyName("chi_square")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ChiSquareHeuristic? ChiSquare { get; set; } /// @@ -50,7 +243,6 @@ public sealed partial class SignificantTextAggregation /// Values to exclude. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -58,7 +250,6 @@ public sealed partial class SignificantTextAggregation /// Determines whether the aggregation will use field values directly or global ordinals. /// /// - [JsonInclude, JsonPropertyName("execution_hint")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -66,7 +257,6 @@ public sealed partial class SignificantTextAggregation /// The field from which to return significant text. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } /// @@ -74,7 +264,6 @@ public sealed partial class SignificantTextAggregation /// Whether to out duplicate text to deal with noisy data. /// /// - [JsonInclude, JsonPropertyName("filter_duplicate_text")] public bool? FilterDuplicateText { get; set; } /// @@ -82,7 +271,6 @@ public sealed partial class SignificantTextAggregation /// Use Google normalized distance as described in "The Google Similarity Distance", Cilibrasi and Vitanyi, 2007, as the significance score. /// /// - [JsonInclude, JsonPropertyName("gnd")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.GoogleNormalizedDistanceHeuristic? Gnd { get; set; } /// @@ -90,7 +278,6 @@ public sealed partial class SignificantTextAggregation /// Values to include. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsInclude? Include { get; set; } /// @@ -98,7 +285,6 @@ public sealed partial class SignificantTextAggregation /// Use JLH score as the significance score. /// /// - [JsonInclude, JsonPropertyName("jlh")] public Elastic.Clients.Elasticsearch.Serverless.EmptyObject? Jlh { get; set; } /// @@ -106,7 +292,6 @@ public sealed partial class SignificantTextAggregation /// Only return values that are found in more than min_doc_count hits. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public long? MinDocCount { get; set; } /// @@ -114,7 +299,6 @@ public sealed partial class SignificantTextAggregation /// Use mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1, as the significance score. /// /// - [JsonInclude, JsonPropertyName("mutual_information")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MutualInformationHeuristic? MutualInformation { get; set; } /// @@ -122,7 +306,6 @@ public sealed partial class SignificantTextAggregation /// A simple calculation of the number of documents in the foreground sample with a term divided by the number of documents in the background with the term. /// /// - [JsonInclude, JsonPropertyName("percentage")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.PercentageScoreHeuristic? Percentage { get; set; } /// @@ -130,7 +313,6 @@ public sealed partial class SignificantTextAggregation /// Customized score, implemented via a script. /// /// - [JsonInclude, JsonPropertyName("script_heuristic")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.ScriptedHeuristic? ScriptHeuristic { get; set; } /// @@ -139,7 +321,6 @@ public sealed partial class SignificantTextAggregation /// Values will only be considered if their local shard frequency within the set is higher than the shard_min_doc_count. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -148,7 +329,6 @@ public sealed partial class SignificantTextAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -156,7 +336,6 @@ public sealed partial class SignificantTextAggregation /// The number of buckets returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -164,8 +343,6 @@ public sealed partial class SignificantTextAggregation /// Overrides the JSON _source fields from which text will be analyzed. /// /// - [JsonInclude, JsonPropertyName("source_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceFields { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(SignificantTextAggregation significantTextAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.SignificantText(significantTextAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs index 68ac88cf2db..4c8a2e22876 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class SimpleValueAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "simple_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsAggregate.g.cs index cd96a122c42..b0bc0dd307b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsAggregate.g.cs @@ -55,4 +55,6 @@ public sealed partial class StatsAggregate : IAggregate public double Sum { get; init; } [JsonInclude, JsonPropertyName("sum_as_string")] public string? SumAsString { get; init; } + + string IAggregate.Type => "stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs index fa25df9afbd..71c61bf663c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs @@ -49,4 +49,6 @@ public sealed partial class StatsBucketAggregate : IAggregate public double Sum { get; init; } [JsonInclude, JsonPropertyName("sum_as_string")] public string? SumAsString { get; init; } + + string IAggregate.Type => "stats_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs index 04fb7cdb10c..0bd976cf5ff 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class StringRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "srareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs index 1bc02b85d3b..938b81ca357 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class StringRareTermsBucketConverter : JsonConverter +internal sealed partial class StringRareTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override StringRareTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override StringRareTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, StringRareTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringRareTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'StringRareTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringStatsAggregate.g.cs index 8fe673d457a..2281f6a59a6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringStatsAggregate.g.cs @@ -49,4 +49,6 @@ public sealed partial class StringStatsAggregate : IAggregate public int? MinLength { get; init; } [JsonInclude, JsonPropertyName("min_length_as_string")] public string? MinLengthAsString { get; init; } + + string IAggregate.Type => "string_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsAggregate.g.cs index 88ae16d8ebf..73bd0dd67c9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class StringTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "sterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsBucket.g.cs index 013a4dbbaed..1a7cff7812b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/StringTermsBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,56 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class StringTermsBucketConverter : JsonConverter +internal sealed partial class StringTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override StringTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override StringTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - Elastic.Clients.Elasticsearch.Serverless.FieldValue key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propDocCountErrorUpperBound = default; + LocalJsonProperty propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, StringTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'StringTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SumAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SumAggregate.g.cs index 238d466c9b9..bca49073f72 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SumAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/SumAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class SumAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "sum"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs index f17b90e7338..7afc6484399 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TDigestPercentileRanksAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs index bd47ae63781..231e6c6928f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TDigestPercentilesAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TTestAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TTestAggregate.g.cs index d2c7657b542..f26ef9a9dc2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TTestAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TTestAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class TTestAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "t_test"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TermsAggregation.g.cs index 84596ba6190..19a4a9177ed 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TermsAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,200 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class TermsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollectMode = System.Text.Json.JsonEncodedText.Encode("collect_mode"); + private static readonly System.Text.Json.JsonEncodedText PropExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropExecutionHint = System.Text.Json.JsonEncodedText.Encode("execution_hint"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMissingBucket = System.Text.Json.JsonEncodedText.Encode("missing_bucket"); + private static readonly System.Text.Json.JsonEncodedText PropMissingOrder = System.Text.Json.JsonEncodedText.Encode("missing_order"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropShowTermDocCountError = System.Text.Json.JsonEncodedText.Encode("show_term_doc_count_error"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropValueType = System.Text.Json.JsonEncodedText.Encode("value_type"); + + public override TermsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCollectMode = default; + LocalJsonProperty propExclude = default; + LocalJsonProperty propExecutionHint = default; + LocalJsonProperty propField = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propInclude = default; + LocalJsonProperty propMinDocCount = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propMissingBucket = default; + LocalJsonProperty propMissingOrder = default; + LocalJsonProperty>?> propOrder = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propShardMinDocCount = default; + LocalJsonProperty propShardSize = default; + LocalJsonProperty propShowTermDocCountError = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propValueType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryRead(ref reader, options, PropCollectMode)) + { + continue; + } + + if (propExclude.TryRead(ref reader, options, PropExclude)) + { + continue; + } + + if (propExecutionHint.TryRead(ref reader, options, PropExecutionHint)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMissingBucket.TryRead(ref reader, options, PropMissingBucket)) + { + continue; + } + + if (propMissingOrder.TryRead(ref reader, options, PropMissingOrder)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propShowTermDocCountError.TryRead(ref reader, options, PropShowTermDocCountError)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propValueType.TryRead(ref reader, options, PropValueType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsAggregation + { + CollectMode = propCollectMode.Value +, + Exclude = propExclude.Value +, + ExecutionHint = propExecutionHint.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Include = propInclude.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + MissingBucket = propMissingBucket.Value +, + MissingOrder = propMissingOrder.Value +, + Order = propOrder.Value +, + Script = propScript.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + ShowTermDocCountError = propShowTermDocCountError.Value +, + Size = propSize.Value +, + ValueType = propValueType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollectMode, value.CollectMode); + writer.WriteProperty(options, PropExclude, value.Exclude); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMissingBucket, value.MissingBucket); + writer.WriteProperty(options, PropMissingOrder, value.MissingOrder); + writer.WriteProperty(options, PropOrder, value.Order, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropValueType, value.ValueType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsAggregationConverter))] public sealed partial class TermsAggregation { /// @@ -34,7 +229,6 @@ public sealed partial class TermsAggregation /// Determines how child aggregations should be calculated: breadth-first or depth-first. /// /// - [JsonInclude, JsonPropertyName("collect_mode")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -43,7 +237,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -51,7 +244,6 @@ public sealed partial class TermsAggregation /// Determines whether the aggregation will use field values directly or global ordinals. /// /// - [JsonInclude, JsonPropertyName("execution_hint")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -59,9 +251,7 @@ public sealed partial class TermsAggregation /// The field from which to return terms. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -70,7 +260,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.TermsInclude? Include { get; set; } /// @@ -78,7 +267,6 @@ public sealed partial class TermsAggregation /// Only return values that are found in more than min_doc_count hits. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -87,11 +275,8 @@ public sealed partial class TermsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.Serverless.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("missing_bucket")] public bool? MissingBucket { get; set; } - [JsonInclude, JsonPropertyName("missing_order")] public Elastic.Clients.Elasticsearch.Serverless.Aggregations.MissingOrder? MissingOrder { get; set; } /// @@ -100,10 +285,7 @@ public sealed partial class TermsAggregation /// Defaults to sorting by descending document count. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } /// @@ -112,7 +294,6 @@ public sealed partial class TermsAggregation /// Terms will only be considered if their local shard frequency within the set is higher than the shard_min_doc_count. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -121,7 +302,6 @@ public sealed partial class TermsAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -129,7 +309,6 @@ public sealed partial class TermsAggregation /// Set to true to return the doc_count_error_upper_bound, which is an upper bound to the error on the doc_count returned by each shard. /// /// - [JsonInclude, JsonPropertyName("show_term_doc_count_error")] public bool? ShowTermDocCountError { get; set; } /// @@ -137,7 +316,6 @@ public sealed partial class TermsAggregation /// The number of buckets returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -145,7 +323,6 @@ public sealed partial class TermsAggregation /// Coerced unmapped fields into the specified type. /// /// - [JsonInclude, JsonPropertyName("value_type")] public string? ValueType { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(TermsAggregation termsAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.Terms(termsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs index 8eeb3961a76..ca634b32b22 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TimeSeriesAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "time_series"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs index 920d0906f9c..270e227a798 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class TimeSeriesBucketConverter : JsonConverter +internal sealed partial class TimeSeriesBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeSeriesBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override TimeSeriesBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new TimeSeriesBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TimeSeriesBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, TimeSeriesBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeSeriesBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'TimeSeriesBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregate.g.cs index 661c3246f20..59a4bafa9cc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TopHitsAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HitsMetadata Hits { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "top_hits"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregation.g.cs index e61be0c1116..9075a301c07 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopHitsAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,190 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class TopHitsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override TopHitsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propDocvalueFields = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty propField = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propScript = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propSeqNoPrimaryTerm = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propTrackScores = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TopHitsAggregation + { + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Field = propField.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + Missing = propMissing.Value +, + Script = propScript.Value +, + ScriptFields = propScriptFields.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + TrackScores = propTrackScores.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TopHitsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopHitsAggregationConverter))] public sealed partial class TopHitsAggregation { /// @@ -34,7 +219,6 @@ public sealed partial class TopHitsAggregation /// Fields for which to return doc values. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -42,7 +226,6 @@ public sealed partial class TopHitsAggregation /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -50,7 +233,6 @@ public sealed partial class TopHitsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } /// @@ -59,7 +241,6 @@ public sealed partial class TopHitsAggregation /// matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -67,7 +248,6 @@ public sealed partial class TopHitsAggregation /// Starting document offset. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -75,7 +255,6 @@ public sealed partial class TopHitsAggregation /// Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in the search results. /// /// - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; set; } /// @@ -84,9 +263,7 @@ public sealed partial class TopHitsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.Serverless.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } /// @@ -94,7 +271,6 @@ public sealed partial class TopHitsAggregation /// Returns the result of one or more script evaluations for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -102,7 +278,6 @@ public sealed partial class TopHitsAggregation /// If true, returns sequence number and primary term of the last modification of each hit. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -110,7 +285,6 @@ public sealed partial class TopHitsAggregation /// The maximum number of top matching hits to return per bucket. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -119,8 +293,6 @@ public sealed partial class TopHitsAggregation /// By default, the hits are sorted by the score of the main query. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } /// @@ -128,7 +300,6 @@ public sealed partial class TopHitsAggregation /// Selects the fields of the source that are returned. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// @@ -136,8 +307,6 @@ public sealed partial class TopHitsAggregation /// Returns values for the specified stored fields (fields that use the store mapping option). /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } /// @@ -145,7 +314,6 @@ public sealed partial class TopHitsAggregation /// If true, calculates and returns document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -153,7 +321,6 @@ public sealed partial class TopHitsAggregation /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(TopHitsAggregation topHitsAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.TopHits(topHitsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs index 196c66f7a93..a4b88814b3e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TopMetricsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("top")] public IReadOnlyCollection Top { get; init; } + + string IAggregate.Type => "top_metrics"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs index 2fbf37981d7..9993e533789 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; +internal sealed partial class TopMetricsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMetrics = System.Text.Json.JsonEncodedText.Encode("metrics"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override TopMetricsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty?> propMetrics = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propMetrics.TryRead(ref reader, options, PropMetrics, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsValue>))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TopMetricsAggregation + { + Field = propField.Value +, + Metrics = propMetrics.Value +, + Missing = propMissing.Value +, + Script = propScript.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TopMetricsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropMetrics, value.Metrics, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsValue>)); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopMetricsAggregationConverter))] public sealed partial class TopMetricsAggregation { /// @@ -34,7 +119,6 @@ public sealed partial class TopMetricsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field? Field { get; set; } /// @@ -42,8 +126,6 @@ public sealed partial class TopMetricsAggregation /// The fields of the top document to return. /// /// - [JsonInclude, JsonPropertyName("metrics")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Aggregations.TopMetricsValue))] public ICollection? Metrics { get; set; } /// @@ -52,9 +134,7 @@ public sealed partial class TopMetricsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.Serverless.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } /// @@ -62,7 +142,6 @@ public sealed partial class TopMetricsAggregation /// The number of top documents from which to return metrics. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -70,8 +149,6 @@ public sealed partial class TopMetricsAggregation /// The sort order of the documents. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation(TopMetricsAggregation topMetricsAggregation) => Elastic.Clients.Elasticsearch.Serverless.Aggregations.Aggregation.TopMetrics(topMetricsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs index 1c1fbf17411..401d85f19b2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class UnmappedRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "umrareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs index 631e5546508..7234ec5eac9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,49 +28,60 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class UnmappedSamplerAggregateConverter : JsonConverter +internal sealed partial class UnmappedSamplerAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override UnmappedSamplerAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override UnmappedSamplerAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new UnmappedSamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnmappedSamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, UnmappedSamplerAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnmappedSamplerAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'UnmappedSamplerAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +96,6 @@ public sealed partial class UnmappedSamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "unmapped_sampler"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs index 5d1b5dc369d..be3264a1381 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class UnmappedSignificantTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "umsigterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs index cc5108caa82..f24bc066ea2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class UnmappedTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "umterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ValueCountAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ValueCountAggregate.g.cs index c17384089a2..12cbe6c8c86 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ValueCountAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/ValueCountAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class ValueCountAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "value_count"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs index 4007ed3e8a8..3395aca617b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class VariableWidthHistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "variable_width_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs index a088c167857..7c05db98857 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,84 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Aggregations; -internal sealed partial class VariableWidthHistogramBucketConverter : JsonConverter +internal sealed partial class VariableWidthHistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override VariableWidthHistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText PropMaxAsString = System.Text.Json.JsonEncodedText.Encode("max_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText PropMinAsString = System.Text.Json.JsonEncodedText.Encode("min_as_string"); + + public override VariableWidthHistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double key = default; - string? keyAsString = default; - double max = default; - string? maxAsString = default; - double min = default; - string? minAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonProperty propDocCount = default; + LocalJsonProperty propKey = default; + LocalJsonProperty propKeyAsString = default; + LocalJsonProperty propMax = default; + LocalJsonProperty propMaxAsString = default; + LocalJsonProperty propMin = default; + LocalJsonProperty propMinAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } + + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } + + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; + } + + if (propMax.TryRead(ref reader, options, PropMax)) + { + continue; + } + + if (propMaxAsString.TryRead(ref reader, options, PropMaxAsString)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max") - { - max = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_as_string") - { - maxAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "min") - { - min = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "min_as_string") - { - minAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + if (propMin.TryRead(ref reader, options, PropMin)) + { + continue; + } + + if (propMinAsString.TryRead(ref reader, options, PropMinAsString)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new VariableWidthHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString, Max = max, MaxAsString = maxAsString, Min = min, MinAsString = minAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VariableWidthHistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value +, + Max = propMax.Value +, + MaxAsString = propMaxAsString.Value +, + Min = propMin.Value +, + MinAsString = propMinAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, VariableWidthHistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, VariableWidthHistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'VariableWidthHistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + writer.WriteProperty(options, PropMax, value.Max); + writer.WriteProperty(options, PropMaxAsString, value.MaxAsString); + writer.WriteProperty(options, PropMin, value.Min); + writer.WriteProperty(options, PropMinAsString, value.MinAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Serverless.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs index e54a85ecb15..99fb01beb5f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class WeightedAverageAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "weighted_avg"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Analyzers.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Analyzers.g.cs index 6bd7654a3b8..e25cefd2e8a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Analyzers.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Analyzers.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -218,289 +219,238 @@ public AnalyzersDescriptor() : base(new Analyzers()) public AnalyzersDescriptor Whitespace(string analyzerName, WhitespaceAnalyzer whitespaceAnalyzer) => AssignVariant(analyzerName, whitespaceAnalyzer); } -internal sealed partial class AnalyzerInterfaceConverter : JsonConverter +internal sealed partial class AnalyzerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override IAnalyzer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "custom"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "arabic": - return JsonSerializer.Deserialize(ref reader, options); - case "armenian": - return JsonSerializer.Deserialize(ref reader, options); - case "basque": - return JsonSerializer.Deserialize(ref reader, options); - case "bengali": - return JsonSerializer.Deserialize(ref reader, options); - case "brazilian": - return JsonSerializer.Deserialize(ref reader, options); - case "bulgarian": - return JsonSerializer.Deserialize(ref reader, options); - case "catalan": - return JsonSerializer.Deserialize(ref reader, options); - case "chinese": - return JsonSerializer.Deserialize(ref reader, options); - case "cjk": - return JsonSerializer.Deserialize(ref reader, options); - case "custom": - return JsonSerializer.Deserialize(ref reader, options); - case "czech": - return JsonSerializer.Deserialize(ref reader, options); - case "danish": - return JsonSerializer.Deserialize(ref reader, options); - case "dutch": - return JsonSerializer.Deserialize(ref reader, options); - case "english": - return JsonSerializer.Deserialize(ref reader, options); - case "estonian": - return JsonSerializer.Deserialize(ref reader, options); - case "fingerprint": - return JsonSerializer.Deserialize(ref reader, options); - case "finnish": - return JsonSerializer.Deserialize(ref reader, options); - case "french": - return JsonSerializer.Deserialize(ref reader, options); - case "galician": - return JsonSerializer.Deserialize(ref reader, options); - case "german": - return JsonSerializer.Deserialize(ref reader, options); - case "greek": - return JsonSerializer.Deserialize(ref reader, options); - case "hindi": - return JsonSerializer.Deserialize(ref reader, options); - case "hungarian": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_analyzer": - return JsonSerializer.Deserialize(ref reader, options); - case "indonesian": - return JsonSerializer.Deserialize(ref reader, options); - case "irish": - return JsonSerializer.Deserialize(ref reader, options); - case "italian": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji": - return JsonSerializer.Deserialize(ref reader, options); - case "language": - return JsonSerializer.Deserialize(ref reader, options); - case "latvian": - return JsonSerializer.Deserialize(ref reader, options); - case "lithuanian": - return JsonSerializer.Deserialize(ref reader, options); - case "nori": - return JsonSerializer.Deserialize(ref reader, options); - case "norwegian": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "persian": - return JsonSerializer.Deserialize(ref reader, options); - case "portuguese": - return JsonSerializer.Deserialize(ref reader, options); - case "romanian": - return JsonSerializer.Deserialize(ref reader, options); - case "russian": - return JsonSerializer.Deserialize(ref reader, options); - case "serbian": - return JsonSerializer.Deserialize(ref reader, options); - case "simple": - return JsonSerializer.Deserialize(ref reader, options); - case "snowball": - return JsonSerializer.Deserialize(ref reader, options); - case "sorani": - return JsonSerializer.Deserialize(ref reader, options); - case "spanish": - return JsonSerializer.Deserialize(ref reader, options); - case "standard": - return JsonSerializer.Deserialize(ref reader, options); - case "stop": - return JsonSerializer.Deserialize(ref reader, options); - case "swedish": - return JsonSerializer.Deserialize(ref reader, options); - case "thai": - return JsonSerializer.Deserialize(ref reader, options); - case "turkish": - return JsonSerializer.Deserialize(ref reader, options); - case "whitespace": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "arabic" => reader.ReadValue(options), + "armenian" => reader.ReadValue(options), + "basque" => reader.ReadValue(options), + "bengali" => reader.ReadValue(options), + "brazilian" => reader.ReadValue(options), + "bulgarian" => reader.ReadValue(options), + "catalan" => reader.ReadValue(options), + "chinese" => reader.ReadValue(options), + "cjk" => reader.ReadValue(options), + "custom" => reader.ReadValue(options), + "czech" => reader.ReadValue(options), + "danish" => reader.ReadValue(options), + "dutch" => reader.ReadValue(options), + "english" => reader.ReadValue(options), + "estonian" => reader.ReadValue(options), + "fingerprint" => reader.ReadValue(options), + "finnish" => reader.ReadValue(options), + "french" => reader.ReadValue(options), + "galician" => reader.ReadValue(options), + "german" => reader.ReadValue(options), + "greek" => reader.ReadValue(options), + "hindi" => reader.ReadValue(options), + "hungarian" => reader.ReadValue(options), + "icu_analyzer" => reader.ReadValue(options), + "indonesian" => reader.ReadValue(options), + "irish" => reader.ReadValue(options), + "italian" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "kuromoji" => reader.ReadValue(options), + "language" => reader.ReadValue(options), + "latvian" => reader.ReadValue(options), + "lithuanian" => reader.ReadValue(options), + "nori" => reader.ReadValue(options), + "norwegian" => reader.ReadValue(options), + "pattern" => reader.ReadValue(options), + "persian" => reader.ReadValue(options), + "portuguese" => reader.ReadValue(options), + "romanian" => reader.ReadValue(options), + "russian" => reader.ReadValue(options), + "serbian" => reader.ReadValue(options), + "simple" => reader.ReadValue(options), + "snowball" => reader.ReadValue(options), + "sorani" => reader.ReadValue(options), + "spanish" => reader.ReadValue(options), + "standard" => reader.ReadValue(options), + "stop" => reader.ReadValue(options), + "swedish" => reader.ReadValue(options), + "thai" => reader.ReadValue(options), + "turkish" => reader.ReadValue(options), + "whitespace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IAnalyzer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, IAnalyzer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IAnalyzer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "arabic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ArabicAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ArabicAnalyzer)value); + break; case "armenian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ArmenianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ArmenianAnalyzer)value); + break; case "basque": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.BasqueAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.BasqueAnalyzer)value); + break; case "bengali": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.BengaliAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.BengaliAnalyzer)value); + break; case "brazilian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.BrazilianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.BrazilianAnalyzer)value); + break; case "bulgarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.BulgarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.BulgarianAnalyzer)value); + break; case "catalan": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CatalanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CatalanAnalyzer)value); + break; case "chinese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ChineseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ChineseAnalyzer)value); + break; case "cjk": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CjkAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CjkAnalyzer)value); + break; case "custom": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CustomAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CustomAnalyzer)value); + break; case "czech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CzechAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CzechAnalyzer)value); + break; case "danish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.DanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.DanishAnalyzer)value); + break; case "dutch": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.DutchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.DutchAnalyzer)value); + break; case "english": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.EnglishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.EnglishAnalyzer)value); + break; case "estonian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.EstonianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.EstonianAnalyzer)value); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.FingerprintAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.FingerprintAnalyzer)value); + break; case "finnish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.FinnishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.FinnishAnalyzer)value); + break; case "french": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.FrenchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.FrenchAnalyzer)value); + break; case "galician": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.GalicianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.GalicianAnalyzer)value); + break; case "german": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.GermanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.GermanAnalyzer)value); + break; case "greek": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.GreekAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.GreekAnalyzer)value); + break; case "hindi": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.HindiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.HindiAnalyzer)value); + break; case "hungarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.HungarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.HungarianAnalyzer)value); + break; case "icu_analyzer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuAnalyzer)value); + break; case "indonesian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IndonesianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IndonesianAnalyzer)value); + break; case "irish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IrishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IrishAnalyzer)value); + break; case "italian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ItalianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ItalianAnalyzer)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordAnalyzer)value); + break; case "kuromoji": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiAnalyzer)value); + break; case "language": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LanguageAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LanguageAnalyzer)value); + break; case "latvian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LatvianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LatvianAnalyzer)value); + break; case "lithuanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LithuanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LithuanianAnalyzer)value); + break; case "nori": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriAnalyzer)value); + break; case "norwegian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NorwegianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NorwegianAnalyzer)value); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternAnalyzer)value); + break; case "persian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PersianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PersianAnalyzer)value); + break; case "portuguese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PortugueseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PortugueseAnalyzer)value); + break; case "romanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.RomanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.RomanianAnalyzer)value); + break; case "russian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.RussianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.RussianAnalyzer)value); + break; case "serbian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SerbianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SerbianAnalyzer)value); + break; case "simple": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SimpleAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SimpleAnalyzer)value); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SnowballAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SnowballAnalyzer)value); + break; case "sorani": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SoraniAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SoraniAnalyzer)value); + break; case "spanish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SpanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SpanishAnalyzer)value); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StandardAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StandardAnalyzer)value); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StopAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StopAnalyzer)value); + break; case "swedish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SwedishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SwedishAnalyzer)value); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ThaiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ThaiAnalyzer)value); + break; case "turkish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.TurkishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.TurkishAnalyzer)value); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.WhitespaceAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.WhitespaceAnalyzer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IAnalyzer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArabicAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArabicAnalyzer.g.cs index 87783f17690..100c37e77b2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArabicAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArabicAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class ArabicAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ArabicAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ArabicAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ArabicAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ArabicAnalyzerConverter))] public sealed partial class ArabicAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "arabic"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs index cbbf0f7e7f8..783dfbe06e9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class ArmenianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ArmenianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ArmenianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ArmenianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ArmenianAnalyzerConverter))] public sealed partial class ArmenianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "armenian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BasqueAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BasqueAnalyzer.g.cs index 7ab1d7efbd0..9800be225e3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BasqueAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BasqueAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class BasqueAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BasqueAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BasqueAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BasqueAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BasqueAnalyzerConverter))] public sealed partial class BasqueAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "basque"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BengaliAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BengaliAnalyzer.g.cs index 951c03fed86..b1e12355a7b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BengaliAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BengaliAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class BengaliAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BengaliAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BengaliAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BengaliAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BengaliAnalyzerConverter))] public sealed partial class BengaliAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "bengali"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs index 1bde324bc93..3fda222d29e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class BrazilianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BrazilianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BrazilianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BrazilianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BrazilianAnalyzerConverter))] public sealed partial class BrazilianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "brazilian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs index 626ffb4a980..297d0ab96d2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class BulgarianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BulgarianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulgarianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulgarianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulgarianAnalyzerConverter))] public sealed partial class BulgarianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "bulgarian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CatalanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CatalanAnalyzer.g.cs index 05bcbee46aa..12dbd76e7e3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CatalanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CatalanAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class CatalanAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CatalanAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CatalanAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CatalanAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CatalanAnalyzerConverter))] public sealed partial class CatalanAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "catalan"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CharFilters.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CharFilters.g.cs index 2e369133ca6..f6dcdec9ed1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CharFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CharFilters.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -83,65 +84,58 @@ public CharFiltersDescriptor() : base(new CharFilters()) public CharFiltersDescriptor PatternReplace(string charFilterName, PatternReplaceCharFilter patternReplaceCharFilter) => AssignVariant(charFilterName, patternReplaceCharFilter); } -internal sealed partial class CharFilterInterfaceConverter : JsonConverter +internal sealed partial class CharFilterInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ICharFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ICharFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "html_strip": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_normalizer": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_iteration_mark": - return JsonSerializer.Deserialize(ref reader, options); - case "mapping": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_replace": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ICharFilter)); - return null; - } + "html_strip" => reader.ReadValue(options), + "icu_normalizer" => reader.ReadValue(options), + "kuromoji_iteration_mark" => reader.ReadValue(options), + "mapping" => reader.ReadValue(options), + "pattern_replace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ICharFilter)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ICharFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ICharFilter value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "html_strip": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.HtmlStripCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.HtmlStripCharFilter)value); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuNormalizationCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuNormalizationCharFilter)value); + break; case "kuromoji_iteration_mark": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiIterationMarkCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiIterationMarkCharFilter)value); + break; case "mapping": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.MappingCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.MappingCharFilter)value); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternReplaceCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternReplaceCharFilter)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ICharFilter)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ChineseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ChineseAnalyzer.g.cs index 346475e7101..46ac7c7fee7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ChineseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ChineseAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class ChineseAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ChineseAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChineseAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChineseAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ChineseAnalyzerConverter))] public sealed partial class ChineseAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "chinese"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CjkAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CjkAnalyzer.g.cs index 3c5155d81ee..827604213d4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CjkAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CjkAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class CjkAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CjkAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CjkAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CjkAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CjkAnalyzerConverter))] public sealed partial class CjkAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "cjk"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CustomAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CustomAnalyzer.g.cs index 8032c00b2a2..3f45f93256b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CustomAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CustomAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,96 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class CustomAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharFilter = System.Text.Json.JsonEncodedText.Encode("char_filter"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropPositionOffsetGap = System.Text.Json.JsonEncodedText.Encode("position_offset_gap"); + private static readonly System.Text.Json.JsonEncodedText PropTokenizer = System.Text.Json.JsonEncodedText.Encode("tokenizer"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CustomAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propCharFilter = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propPositionIncrementGap = default; + LocalJsonProperty propPositionOffsetGap = default; + LocalJsonProperty propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharFilter.TryRead(ref reader, options, PropCharFilter, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propPositionOffsetGap.TryRead(ref reader, options, PropPositionOffsetGap)) + { + continue; + } + + if (propTokenizer.TryRead(ref reader, options, PropTokenizer)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CustomAnalyzer + { + CharFilter = propCharFilter.Value +, + Filter = propFilter.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + PositionOffsetGap = propPositionOffsetGap.Value +, + Tokenizer = propTokenizer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CustomAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharFilter, value.CharFilter, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropPositionOffsetGap, value.PositionOffsetGap); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CustomAnalyzerConverter))] public sealed partial class CustomAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("char_filter")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? CharFilter { get; set; } - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Filter { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("position_offset_gap")] public int? PositionOffsetGap { get; set; } - [JsonInclude, JsonPropertyName("tokenizer")] public string Tokenizer { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "custom"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CzechAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CzechAnalyzer.g.cs index 2ab33835403..cf65bcfb93a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CzechAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/CzechAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class CzechAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CzechAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CzechAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CzechAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CzechAnalyzerConverter))] public sealed partial class CzechAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "czech"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DanishAnalyzer.g.cs index 1a564e5d309..58acdec1254 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DanishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class DanishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DanishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DanishAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DanishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DanishAnalyzerConverter))] public sealed partial class DanishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "danish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DutchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DutchAnalyzer.g.cs index 988e5393d2c..233044ee209 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DutchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/DutchAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class DutchAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DutchAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DutchAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DutchAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DutchAnalyzerConverter))] public sealed partial class DutchAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "dutch"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EnglishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EnglishAnalyzer.g.cs index f7840444ac6..eb2f1bdc707 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EnglishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EnglishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class EnglishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override EnglishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnglishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnglishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnglishAnalyzerConverter))] public sealed partial class EnglishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "english"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EstonianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EstonianAnalyzer.g.cs index 33b4a41442b..e30ac706990 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EstonianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/EstonianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class EstonianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override EstonianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EstonianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EstonianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EstonianAnalyzerConverter))] public sealed partial class EstonianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "estonian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs index bb792973a82..d9069d7bb1c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,108 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class FingerprintAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMaxOutputSize = System.Text.Json.JsonEncodedText.Encode("max_output_size"); + private static readonly System.Text.Json.JsonEncodedText PropPreserveOriginal = System.Text.Json.JsonEncodedText.Encode("preserve_original"); + private static readonly System.Text.Json.JsonEncodedText PropSeparator = System.Text.Json.JsonEncodedText.Encode("separator"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override FingerprintAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propMaxOutputSize = default; + LocalJsonProperty propPreserveOriginal = default; + LocalJsonProperty propSeparator = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxOutputSize.TryRead(ref reader, options, PropMaxOutputSize)) + { + continue; + } + + if (propPreserveOriginal.TryRead(ref reader, options, PropPreserveOriginal)) + { + continue; + } + + if (propSeparator.TryRead(ref reader, options, PropSeparator)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FingerprintAnalyzer + { + MaxOutputSize = propMaxOutputSize.Value +, + PreserveOriginal = propPreserveOriginal.Value +, + Separator = propSeparator.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMaxOutputSize, value.MaxOutputSize); + writer.WriteProperty(options, PropPreserveOriginal, value.PreserveOriginal); + writer.WriteProperty(options, PropSeparator, value.Separator); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FingerprintAnalyzerConverter))] public sealed partial class FingerprintAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("max_output_size")] public int MaxOutputSize { get; set; } - [JsonInclude, JsonPropertyName("preserve_original")] public bool PreserveOriginal { get; set; } - [JsonInclude, JsonPropertyName("separator")] public string Separator { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "fingerprint"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FinnishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FinnishAnalyzer.g.cs index ac99cc9a655..97e93f1ecec 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FinnishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FinnishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class FinnishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FinnishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FinnishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FinnishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FinnishAnalyzerConverter))] public sealed partial class FinnishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "finnish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FrenchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FrenchAnalyzer.g.cs index f24252dbd45..62e19a0afeb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FrenchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/FrenchAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class FrenchAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FrenchAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FrenchAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FrenchAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FrenchAnalyzerConverter))] public sealed partial class FrenchAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "french"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GalicianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GalicianAnalyzer.g.cs index 7d2d6eb67b6..e02cdba8c8c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GalicianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GalicianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class GalicianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GalicianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GalicianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GalicianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GalicianAnalyzerConverter))] public sealed partial class GalicianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "galician"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GermanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GermanAnalyzer.g.cs index 3ac9153d3fb..039321a6971 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GermanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GermanAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class GermanAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GermanAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GermanAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GermanAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GermanAnalyzerConverter))] public sealed partial class GermanAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "german"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GreekAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GreekAnalyzer.g.cs index 2cdd8a4115a..75604c867d6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GreekAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/GreekAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class GreekAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GreekAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GreekAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GreekAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GreekAnalyzerConverter))] public sealed partial class GreekAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "greek"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HindiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HindiAnalyzer.g.cs index 0e765e00b40..8b119b6f94c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HindiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HindiAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class HindiAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HindiAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HindiAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HindiAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HindiAnalyzerConverter))] public sealed partial class HindiAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "hindi"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HungarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HungarianAnalyzer.g.cs index a03ae71fec5..aa744892275 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HungarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/HungarianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class HungarianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HungarianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HungarianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HungarianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HungarianAnalyzerConverter))] public sealed partial class HungarianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "hungarian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs index 2d51e30cdad..29c31ae3e4d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class IndonesianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IndonesianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndonesianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndonesianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndonesianAnalyzerConverter))] public sealed partial class IndonesianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "indonesian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IrishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IrishAnalyzer.g.cs index bc0b931d3ea..9a22f20cf47 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IrishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/IrishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class IrishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IrishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IrishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IrishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IrishAnalyzerConverter))] public sealed partial class IrishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "irish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ItalianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ItalianAnalyzer.g.cs index 6f27eb0afdf..2b38b8e5889 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ItalianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ItalianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class ItalianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ItalianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ItalianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ItalianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ItalianAnalyzerConverter))] public sealed partial class ItalianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "italian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs index 63c98e51412..ee934ff4eb4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,97 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class KeywordMarkerTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIgnoreCase = System.Text.Json.JsonEncodedText.Encode("ignore_case"); + private static readonly System.Text.Json.JsonEncodedText PropKeywords = System.Text.Json.JsonEncodedText.Encode("keywords"); + private static readonly System.Text.Json.JsonEncodedText PropKeywordsPath = System.Text.Json.JsonEncodedText.Encode("keywords_path"); + private static readonly System.Text.Json.JsonEncodedText PropKeywordsPattern = System.Text.Json.JsonEncodedText.Encode("keywords_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override KeywordMarkerTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propIgnoreCase = default; + LocalJsonProperty?> propKeywords = default; + LocalJsonProperty propKeywordsPath = default; + LocalJsonProperty propKeywordsPattern = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryRead(ref reader, options, PropIgnoreCase)) + { + continue; + } + + if (propKeywords.TryRead(ref reader, options, PropKeywords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propKeywordsPath.TryRead(ref reader, options, PropKeywordsPath)) + { + continue; + } + + if (propKeywordsPattern.TryRead(ref reader, options, PropKeywordsPattern)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KeywordMarkerTokenFilter + { + IgnoreCase = propIgnoreCase.Value +, + Keywords = propKeywords.Value +, + KeywordsPath = propKeywordsPath.Value +, + KeywordsPattern = propKeywordsPattern.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeywordMarkerTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIgnoreCase, value.IgnoreCase); + writer.WriteProperty(options, PropKeywords, value.Keywords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropKeywordsPath, value.KeywordsPath); + writer.WriteProperty(options, PropKeywordsPattern, value.KeywordsPattern); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KeywordMarkerTokenFilterConverter))] public sealed partial class KeywordMarkerTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("ignore_case")] public bool? IgnoreCase { get; set; } - [JsonInclude, JsonPropertyName("keywords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Keywords { get; set; } - [JsonInclude, JsonPropertyName("keywords_path")] public string? KeywordsPath { get; set; } - [JsonInclude, JsonPropertyName("keywords_pattern")] public string? KeywordsPattern { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "keyword_marker"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LanguageAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LanguageAnalyzer.g.cs index 0728851d857..f6b5c6cf88b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LanguageAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LanguageAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,97 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class LanguageAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override LanguageAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLanguage = default; + LocalJsonProperty> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LanguageAnalyzer + { + Language = propLanguage.Value +, + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LanguageAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LanguageAnalyzerConverter))] public sealed partial class LanguageAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.Language Language { get; set; } - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "language"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LatvianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LatvianAnalyzer.g.cs index a14c5062cbb..e85f04ccc47 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LatvianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LatvianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class LatvianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LatvianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LatvianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LatvianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LatvianAnalyzerConverter))] public sealed partial class LatvianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "latvian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs index b676f04e394..3fb8e3c4812 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class LithuanianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LithuanianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LithuanianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LithuanianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LithuanianAnalyzerConverter))] public sealed partial class LithuanianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "lithuanian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Normalizers.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Normalizers.g.cs index e5111e9b1b4..3843ccc02a8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Normalizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Normalizers.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -74,49 +75,46 @@ public NormalizersDescriptor() : base(new Normalizers()) public NormalizersDescriptor Lowercase(string normalizerName, LowercaseNormalizer lowercaseNormalizer) => AssignVariant(normalizerName, lowercaseNormalizer); } -internal sealed partial class NormalizerInterfaceConverter : JsonConverter +internal sealed partial class NormalizerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override INormalizer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override INormalizer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "custom"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "custom": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "custom" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(INormalizer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, INormalizer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, INormalizer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "custom": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CustomNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CustomNormalizer)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseNormalizer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(INormalizer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs index 5b88623985b..7fcfaeeef74 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class NorwegianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NorwegianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NorwegianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NorwegianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NorwegianAnalyzerConverter))] public sealed partial class NorwegianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "norwegian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PatternAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PatternAnalyzer.g.cs index 93bf278a294..a2252105c4a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PatternAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PatternAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,97 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class PatternAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropLowercase = System.Text.Json.JsonEncodedText.Encode("lowercase"); + private static readonly System.Text.Json.JsonEncodedText PropPattern = System.Text.Json.JsonEncodedText.Encode("pattern"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PatternAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFlags = default; + LocalJsonProperty propLowercase = default; + LocalJsonProperty propPattern = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } + + if (propLowercase.TryRead(ref reader, options, PropLowercase)) + { + continue; + } + + if (propPattern.TryRead(ref reader, options, PropPattern)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PatternAnalyzer + { + Flags = propFlags.Value +, + Lowercase = propLowercase.Value +, + Pattern = propPattern.Value +, + Stopwords = propStopwords.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PatternAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropLowercase, value.Lowercase); + writer.WriteProperty(options, PropPattern, value.Pattern); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PatternAnalyzerConverter))] public sealed partial class PatternAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("flags")] public string? Flags { get; set; } - [JsonInclude, JsonPropertyName("lowercase")] public bool? Lowercase { get; set; } - [JsonInclude, JsonPropertyName("pattern")] public string Pattern { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "pattern"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PersianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PersianAnalyzer.g.cs index ea3eaf1c040..1b6a9968e32 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PersianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PersianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class PersianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PersianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PersianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PersianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PersianAnalyzerConverter))] public sealed partial class PersianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "persian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs index 3a1e45c2e51..8f2a12e6a52 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,119 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class PhoneticTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEncoder = System.Text.Json.JsonEncodedText.Encode("encoder"); + private static readonly System.Text.Json.JsonEncodedText PropLanguageset = System.Text.Json.JsonEncodedText.Encode("languageset"); + private static readonly System.Text.Json.JsonEncodedText PropMaxCodeLen = System.Text.Json.JsonEncodedText.Encode("max_code_len"); + private static readonly System.Text.Json.JsonEncodedText PropNameType = System.Text.Json.JsonEncodedText.Encode("name_type"); + private static readonly System.Text.Json.JsonEncodedText PropReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText PropRuleType = System.Text.Json.JsonEncodedText.Encode("rule_type"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PhoneticTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propEncoder = default; + LocalJsonProperty?> propLanguageset = default; + LocalJsonProperty propMaxCodeLen = default; + LocalJsonProperty propNameType = default; + LocalJsonProperty propReplace = default; + LocalJsonProperty propRuleType = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEncoder.TryRead(ref reader, options, PropEncoder)) + { + continue; + } + + if (propLanguageset.TryRead(ref reader, options, PropLanguageset, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticLanguage>))) + { + continue; + } + + if (propMaxCodeLen.TryRead(ref reader, options, PropMaxCodeLen)) + { + continue; + } + + if (propNameType.TryRead(ref reader, options, PropNameType)) + { + continue; + } + + if (propReplace.TryRead(ref reader, options, PropReplace)) + { + continue; + } + + if (propRuleType.TryRead(ref reader, options, PropRuleType)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PhoneticTokenFilter + { + Encoder = propEncoder.Value +, + Languageset = propLanguageset.Value +, + MaxCodeLen = propMaxCodeLen.Value +, + NameType = propNameType.Value +, + Replace = propReplace.Value +, + RuleType = propRuleType.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEncoder, value.Encoder); + writer.WriteProperty(options, PropLanguageset, value.Languageset, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticLanguage>)); + writer.WriteProperty(options, PropMaxCodeLen, value.MaxCodeLen); + writer.WriteProperty(options, PropNameType, value.NameType); + writer.WriteProperty(options, PropReplace, value.Replace); + writer.WriteProperty(options, PropRuleType, value.RuleType); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhoneticTokenFilterConverter))] public sealed partial class PhoneticTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("encoder")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticEncoder Encoder { get; set; } - [JsonInclude, JsonPropertyName("languageset")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticLanguage))] public ICollection? Languageset { get; set; } - [JsonInclude, JsonPropertyName("max_code_len")] public int? MaxCodeLen { get; set; } - [JsonInclude, JsonPropertyName("name_type")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticNameType? NameType { get; set; } - [JsonInclude, JsonPropertyName("replace")] public bool? Replace { get; set; } - [JsonInclude, JsonPropertyName("rule_type")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticRuleType? RuleType { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "phonetic"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs index 0344ea7173f..934ef0ebd58 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class PortugueseAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PortugueseAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PortugueseAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PortugueseAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PortugueseAnalyzerConverter))] public sealed partial class PortugueseAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "portuguese"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RomanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RomanianAnalyzer.g.cs index 37809cd82ef..b3ae3da376e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RomanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RomanianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class RomanianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override RomanianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RomanianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RomanianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RomanianAnalyzerConverter))] public sealed partial class RomanianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "romanian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RussianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RussianAnalyzer.g.cs index 8547f3c2ad7..827ab688f19 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RussianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/RussianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class RussianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override RussianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RussianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RussianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RussianAnalyzerConverter))] public sealed partial class RussianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "russian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SerbianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SerbianAnalyzer.g.cs index 9e978353e75..76162929c20 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SerbianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SerbianAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class SerbianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SerbianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SerbianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SerbianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SerbianAnalyzerConverter))] public sealed partial class SerbianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "serbian"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SnowballAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SnowballAnalyzer.g.cs index 98cb613c3b6..7be96fd4cc5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SnowballAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SnowballAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class SnowballAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SnowballAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLanguage = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SnowballAnalyzer + { + Language = propLanguage.Value +, + Stopwords = propStopwords.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnowballAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SnowballAnalyzerConverter))] public sealed partial class SnowballAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.SnowballLanguage Language { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "snowball"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SoraniAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SoraniAnalyzer.g.cs index f96bef1f1c9..7d41a9229ff 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SoraniAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SoraniAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class SoraniAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SoraniAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SoraniAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SoraniAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SoraniAnalyzerConverter))] public sealed partial class SoraniAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "sorani"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SpanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SpanishAnalyzer.g.cs index 7c67c7c246e..02dfe7b0546 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SpanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SpanishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class SpanishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SpanishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SpanishAnalyzerConverter))] public sealed partial class SpanishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "spanish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StandardAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StandardAnalyzer.g.cs index e064b2c5e0a..923d0e71892 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StandardAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StandardAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class StandardAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMaxTokenLength = System.Text.Json.JsonEncodedText.Encode("max_token_length"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override StandardAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propMaxTokenLength = default; + LocalJsonProperty?> propStopwords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxTokenLength.TryRead(ref reader, options, PropMaxTokenLength)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StandardAnalyzer + { + MaxTokenLength = propMaxTokenLength.Value +, + Stopwords = propStopwords.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StandardAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMaxTokenLength, value.MaxTokenLength); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StandardAnalyzerConverter))] public sealed partial class StandardAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("max_token_length")] public int? MaxTokenLength { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "standard"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StemmerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StemmerTokenFilter.g.cs index 3803785787e..1cd7d836c80 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StemmerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StemmerTokenFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,52 +28,54 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; -internal sealed partial class StemmerTokenFilterConverter : JsonConverter +internal sealed partial class StemmerTokenFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override StemmerTokenFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropLanguage1 = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StemmerTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new StemmerTokenFilter(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLanguage = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propLanguage.TryRead(ref reader, options, PropLanguage) || propLanguage.TryRead(ref reader, options, PropLanguage1)) { - var property = reader.GetString(); - if (property == "language" || property == "name") - { - variant.Language = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } - public override void Write(Utf8JsonWriter writer, StemmerTokenFilter value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Language)) - { - writer.WritePropertyName("language"); - writer.WriteStringValue(value.Language); + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - writer.WritePropertyName("type"); - writer.WriteStringValue("stemmer"); - if (!string.IsNullOrEmpty(value.Version)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StemmerTokenFilter { - writer.WritePropertyName("version"); - writer.WriteStringValue(value.Version); - } + Language = propLanguage.Value +, + Version = propVersion.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, StemmerTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopAnalyzer.g.cs index 29e73833d84..4cf328ecdd4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class StopAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StopAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopAnalyzerConverter))] public sealed partial class StopAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "stop"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopTokenFilter.g.cs index 59989df0afc..fdca03d0e40 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/StopTokenFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,97 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class StopTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIgnoreCase = System.Text.Json.JsonEncodedText.Encode("ignore_case"); + private static readonly System.Text.Json.JsonEncodedText PropRemoveTrailing = System.Text.Json.JsonEncodedText.Encode("remove_trailing"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StopTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propIgnoreCase = default; + LocalJsonProperty propRemoveTrailing = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryRead(ref reader, options, PropIgnoreCase)) + { + continue; + } + + if (propRemoveTrailing.TryRead(ref reader, options, PropRemoveTrailing)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTokenFilter + { + IgnoreCase = propIgnoreCase.Value +, + RemoveTrailing = propRemoveTrailing.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIgnoreCase, value.IgnoreCase); + writer.WriteProperty(options, PropRemoveTrailing, value.RemoveTrailing); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTokenFilterConverter))] public sealed partial class StopTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("ignore_case")] public bool? IgnoreCase { get; set; } - [JsonInclude, JsonPropertyName("remove_trailing")] public bool? RemoveTrailing { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "stop"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SwedishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SwedishAnalyzer.g.cs index ae01149d2e9..2e80789ca4f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SwedishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/SwedishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class SwedishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SwedishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SwedishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SwedishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SwedishAnalyzerConverter))] public sealed partial class SwedishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "swedish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ThaiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ThaiAnalyzer.g.cs index bdf26a797f3..049c5edc287 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ThaiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/ThaiAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class ThaiAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ThaiAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ThaiAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ThaiAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ThaiAnalyzerConverter))] public sealed partial class ThaiAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "thai"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TokenFilters.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TokenFilters.g.cs index 5d05ae0174c..8ad112ac2cc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TokenFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TokenFilters.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -209,275 +210,226 @@ public TokenFiltersDescriptor() : base(new TokenFilters()) public TokenFiltersDescriptor WordDelimiter(string tokenFilterName, WordDelimiterTokenFilter wordDelimiterTokenFilter) => AssignVariant(tokenFilterName, wordDelimiterTokenFilter); } -internal sealed partial class TokenFilterInterfaceConverter : JsonConverter +internal sealed partial class TokenFilterInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ITokenFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ITokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "asciifolding": - return JsonSerializer.Deserialize(ref reader, options); - case "common_grams": - return JsonSerializer.Deserialize(ref reader, options); - case "condition": - return JsonSerializer.Deserialize(ref reader, options); - case "delimited_payload": - return JsonSerializer.Deserialize(ref reader, options); - case "dictionary_decompounder": - return JsonSerializer.Deserialize(ref reader, options); - case "edge_ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "elision": - return JsonSerializer.Deserialize(ref reader, options); - case "fingerprint": - return JsonSerializer.Deserialize(ref reader, options); - case "hunspell": - return JsonSerializer.Deserialize(ref reader, options); - case "hyphenation_decompounder": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_collation": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_folding": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_normalizer": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_transform": - return JsonSerializer.Deserialize(ref reader, options); - case "keep_types": - return JsonSerializer.Deserialize(ref reader, options); - case "keep": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword_marker": - return JsonSerializer.Deserialize(ref reader, options); - case "kstem": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_part_of_speech": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_readingform": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_stemmer": - return JsonSerializer.Deserialize(ref reader, options); - case "length": - return JsonSerializer.Deserialize(ref reader, options); - case "limit": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - case "multiplexer": - return JsonSerializer.Deserialize(ref reader, options); - case "ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "nori_part_of_speech": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_capture": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_replace": - return JsonSerializer.Deserialize(ref reader, options); - case "phonetic": - return JsonSerializer.Deserialize(ref reader, options); - case "porter_stem": - return JsonSerializer.Deserialize(ref reader, options); - case "predicate_token_filter": - return JsonSerializer.Deserialize(ref reader, options); - case "remove_duplicates": - return JsonSerializer.Deserialize(ref reader, options); - case "reverse": - return JsonSerializer.Deserialize(ref reader, options); - case "shingle": - return JsonSerializer.Deserialize(ref reader, options); - case "snowball": - return JsonSerializer.Deserialize(ref reader, options); - case "stemmer_override": - return JsonSerializer.Deserialize(ref reader, options); - case "stemmer": - return JsonSerializer.Deserialize(ref reader, options); - case "stop": - return JsonSerializer.Deserialize(ref reader, options); - case "synonym_graph": - return JsonSerializer.Deserialize(ref reader, options); - case "synonym": - return JsonSerializer.Deserialize(ref reader, options); - case "trim": - return JsonSerializer.Deserialize(ref reader, options); - case "truncate": - return JsonSerializer.Deserialize(ref reader, options); - case "unique": - return JsonSerializer.Deserialize(ref reader, options); - case "uppercase": - return JsonSerializer.Deserialize(ref reader, options); - case "word_delimiter_graph": - return JsonSerializer.Deserialize(ref reader, options); - case "word_delimiter": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenFilter)); - return null; - } + "asciifolding" => reader.ReadValue(options), + "common_grams" => reader.ReadValue(options), + "condition" => reader.ReadValue(options), + "delimited_payload" => reader.ReadValue(options), + "dictionary_decompounder" => reader.ReadValue(options), + "edge_ngram" => reader.ReadValue(options), + "elision" => reader.ReadValue(options), + "fingerprint" => reader.ReadValue(options), + "hunspell" => reader.ReadValue(options), + "hyphenation_decompounder" => reader.ReadValue(options), + "icu_collation" => reader.ReadValue(options), + "icu_folding" => reader.ReadValue(options), + "icu_normalizer" => reader.ReadValue(options), + "icu_transform" => reader.ReadValue(options), + "keep_types" => reader.ReadValue(options), + "keep" => reader.ReadValue(options), + "keyword_marker" => reader.ReadValue(options), + "kstem" => reader.ReadValue(options), + "kuromoji_part_of_speech" => reader.ReadValue(options), + "kuromoji_readingform" => reader.ReadValue(options), + "kuromoji_stemmer" => reader.ReadValue(options), + "length" => reader.ReadValue(options), + "limit" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + "multiplexer" => reader.ReadValue(options), + "ngram" => reader.ReadValue(options), + "nori_part_of_speech" => reader.ReadValue(options), + "pattern_capture" => reader.ReadValue(options), + "pattern_replace" => reader.ReadValue(options), + "phonetic" => reader.ReadValue(options), + "porter_stem" => reader.ReadValue(options), + "predicate_token_filter" => reader.ReadValue(options), + "remove_duplicates" => reader.ReadValue(options), + "reverse" => reader.ReadValue(options), + "shingle" => reader.ReadValue(options), + "snowball" => reader.ReadValue(options), + "stemmer_override" => reader.ReadValue(options), + "stemmer" => reader.ReadValue(options), + "stop" => reader.ReadValue(options), + "synonym_graph" => reader.ReadValue(options), + "synonym" => reader.ReadValue(options), + "trim" => reader.ReadValue(options), + "truncate" => reader.ReadValue(options), + "unique" => reader.ReadValue(options), + "uppercase" => reader.ReadValue(options), + "word_delimiter_graph" => reader.ReadValue(options), + "word_delimiter" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ITokenFilter)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ITokenFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ITokenFilter value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "asciifolding": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.AsciiFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.AsciiFoldingTokenFilter)value); + break; case "common_grams": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CommonGramsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CommonGramsTokenFilter)value); + break; case "condition": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ConditionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ConditionTokenFilter)value); + break; case "delimited_payload": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.DelimitedPayloadTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.DelimitedPayloadTokenFilter)value); + break; case "dictionary_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.DictionaryDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.DictionaryDecompounderTokenFilter)value); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.EdgeNGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.EdgeNGramTokenFilter)value); + break; case "elision": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ElisionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ElisionTokenFilter)value); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.FingerprintTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.FingerprintTokenFilter)value); + break; case "hunspell": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.HunspellTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.HunspellTokenFilter)value); + break; case "hyphenation_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.HyphenationDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.HyphenationDecompounderTokenFilter)value); + break; case "icu_collation": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationTokenFilter)value); + break; case "icu_folding": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuFoldingTokenFilter)value); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuNormalizationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuNormalizationTokenFilter)value); + break; case "icu_transform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuTransformTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuTransformTokenFilter)value); + break; case "keep_types": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KeepTypesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KeepTypesTokenFilter)value); + break; case "keep": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KeepWordsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KeepWordsTokenFilter)value); + break; case "keyword_marker": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordMarkerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordMarkerTokenFilter)value); + break; case "kstem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KStemTokenFilter)value); + break; case "kuromoji_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiPartOfSpeechTokenFilter)value); + break; case "kuromoji_readingform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiReadingFormTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiReadingFormTokenFilter)value); + break; case "kuromoji_stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiStemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiStemmerTokenFilter)value); + break; case "length": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LengthTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LengthTokenFilter)value); + break; case "limit": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LimitTokenCountTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LimitTokenCountTokenFilter)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseTokenFilter)value); + break; case "multiplexer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.MultiplexerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.MultiplexerTokenFilter)value); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NGramTokenFilter)value); + break; case "nori_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriPartOfSpeechTokenFilter)value); + break; case "pattern_capture": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternCaptureTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternCaptureTokenFilter)value); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternReplaceTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternReplaceTokenFilter)value); + break; case "phonetic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PhoneticTokenFilter)value); + break; case "porter_stem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PorterStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PorterStemTokenFilter)value); + break; case "predicate_token_filter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PredicateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PredicateTokenFilter)value); + break; case "remove_duplicates": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.RemoveDuplicatesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.RemoveDuplicatesTokenFilter)value); + break; case "reverse": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ReverseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ReverseTokenFilter)value); + break; case "shingle": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ShingleTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ShingleTokenFilter)value); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SnowballTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SnowballTokenFilter)value); + break; case "stemmer_override": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StemmerOverrideTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StemmerOverrideTokenFilter)value); + break; case "stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StemmerTokenFilter)value); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StopTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StopTokenFilter)value); + break; case "synonym_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SynonymGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SynonymGraphTokenFilter)value); + break; case "synonym": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SynonymTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SynonymTokenFilter)value); + break; case "trim": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.TrimTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.TrimTokenFilter)value); + break; case "truncate": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.TruncateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.TruncateTokenFilter)value); + break; case "unique": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.UniqueTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.UniqueTokenFilter)value); + break; case "uppercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.UppercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.UppercaseTokenFilter)value); + break; case "word_delimiter_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.WordDelimiterGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.WordDelimiterGraphTokenFilter)value); + break; case "word_delimiter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.WordDelimiterTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.WordDelimiterTokenFilter)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ITokenFilter)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Tokenizers.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Tokenizers.g.cs index 0e3c17b8211..70daafe006c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Tokenizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/Tokenizers.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -122,130 +123,110 @@ public TokenizersDescriptor() : base(new Tokenizers()) public TokenizersDescriptor Whitespace(string tokenizerName, WhitespaceTokenizer whitespaceTokenizer) => AssignVariant(tokenizerName, whitespaceTokenizer); } -internal sealed partial class TokenizerInterfaceConverter : JsonConverter +internal sealed partial class TokenizerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ITokenizer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ITokenizer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "char_group": - return JsonSerializer.Deserialize(ref reader, options); - case "classic": - return JsonSerializer.Deserialize(ref reader, options); - case "edge_ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "letter": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - case "ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "nori_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "path_hierarchy": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "simple_pattern_split": - return JsonSerializer.Deserialize(ref reader, options); - case "simple_pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "standard": - return JsonSerializer.Deserialize(ref reader, options); - case "thai": - return JsonSerializer.Deserialize(ref reader, options); - case "uax_url_email": - return JsonSerializer.Deserialize(ref reader, options); - case "whitespace": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenizer)); - return null; - } + "char_group" => reader.ReadValue(options), + "classic" => reader.ReadValue(options), + "edge_ngram" => reader.ReadValue(options), + "icu_tokenizer" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "kuromoji_tokenizer" => reader.ReadValue(options), + "letter" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + "ngram" => reader.ReadValue(options), + "nori_tokenizer" => reader.ReadValue(options), + "path_hierarchy" => reader.ReadValue(options), + "pattern" => reader.ReadValue(options), + "simple_pattern_split" => reader.ReadValue(options), + "simple_pattern" => reader.ReadValue(options), + "standard" => reader.ReadValue(options), + "thai" => reader.ReadValue(options), + "uax_url_email" => reader.ReadValue(options), + "whitespace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ITokenizer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ITokenizer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ITokenizer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "char_group": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.CharGroupTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.CharGroupTokenizer)value); + break; case "classic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ClassicTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ClassicTokenizer)value); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.EdgeNGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.EdgeNGramTokenizer)value); + break; case "icu_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuTokenizer)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KeywordTokenizer)value); + break; case "kuromoji_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.KuromojiTokenizer)value); + break; case "letter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LetterTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LetterTokenizer)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.LowercaseTokenizer)value); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NGramTokenizer)value); + break; case "nori_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.NoriTokenizer)value); + break; case "path_hierarchy": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PathHierarchyTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PathHierarchyTokenizer)value); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.PatternTokenizer)value); + break; case "simple_pattern_split": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SimplePatternSplitTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SimplePatternSplitTokenizer)value); + break; case "simple_pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.SimplePatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.SimplePatternTokenizer)value); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.StandardTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.StandardTokenizer)value); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.ThaiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.ThaiTokenizer)value); + break; case "uax_url_email": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.UaxEmailUrlTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.UaxEmailUrlTokenizer)value); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Analysis.WhitespaceTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Analysis.WhitespaceTokenizer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ITokenizer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TurkishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TurkishAnalyzer.g.cs index d4a02ced9d7..c45cbabac08 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TurkishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Analysis/TurkishAnalyzer.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Analysis; +internal sealed partial class TurkishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TurkishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propStemExclusion = default; + LocalJsonProperty?> propStopwords = default; + LocalJsonProperty propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TurkishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TurkishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TurkishAnalyzerConverter))] public sealed partial class TurkishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "turkish"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs index fb48da5840f..f189d30666d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs @@ -38,7 +38,6 @@ public sealed partial class ComponentTemplateSummary [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("settings")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexSettings))] public IReadOnlyDictionary? Settings { get; init; } [JsonInclude, JsonPropertyName("version")] public long? Version { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/CompletionStats.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/CompletionStats.g.cs index 98ef24f22fe..211bf5dbb8c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/CompletionStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/CompletionStats.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Serverless; public sealed partial class CompletionStats { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.FieldSizeUsage))] public IReadOnlyDictionary? Fields { get; init; } /// diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs index fb55120aeb0..16ff9892917 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.FieldCaps; +internal sealed partial class FieldCapabilityConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregatable = System.Text.Json.JsonEncodedText.Encode("aggregatable"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropMetadataField = System.Text.Json.JsonEncodedText.Encode("metadata_field"); + private static readonly System.Text.Json.JsonEncodedText PropNonAggregatableIndices = System.Text.Json.JsonEncodedText.Encode("non_aggregatable_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonSearchableIndices = System.Text.Json.JsonEncodedText.Encode("non_searchable_indices"); + private static readonly System.Text.Json.JsonEncodedText PropSearchable = System.Text.Json.JsonEncodedText.Encode("searchable"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FieldCapability Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAggregatable = default; + LocalJsonProperty?> propIndices = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propMetadataField = default; + LocalJsonProperty?> propNonAggregatableIndices = default; + LocalJsonProperty?> propNonSearchableIndices = default; + LocalJsonProperty propSearchable = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregatable.TryRead(ref reader, options, PropAggregatable)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propMetadataField.TryRead(ref reader, options, PropMetadataField)) + { + continue; + } + + if (propNonAggregatableIndices.TryRead(ref reader, options, PropNonAggregatableIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propNonSearchableIndices.TryRead(ref reader, options, PropNonSearchableIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propSearchable.TryRead(ref reader, options, PropSearchable)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapability + { + Aggregatable = propAggregatable.Value +, + Indices = propIndices.Value +, + Meta = propMeta.Value +, + MetadataField = propMetadataField.Value +, + NonAggregatableIndices = propNonAggregatableIndices.Value +, + NonSearchableIndices = propNonSearchableIndices.Value +, + Searchable = propSearchable.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapability value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregatable, value.Aggregatable); + writer.WriteProperty(options, PropIndices, value.Indices, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropMetadataField, value.MetadataField); + writer.WriteProperty(options, PropNonAggregatableIndices, value.NonAggregatableIndices, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropNonSearchableIndices, value.NonSearchableIndices, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropSearchable, value.Searchable); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCapabilityConverter))] public sealed partial class FieldCapability { /// @@ -34,7 +139,6 @@ public sealed partial class FieldCapability /// Whether this field can be aggregated on all indices. /// /// - [JsonInclude, JsonPropertyName("aggregatable")] public bool Aggregatable { get; init; } /// @@ -42,8 +146,6 @@ public sealed partial class FieldCapability /// The list of indices where this field has the same type family, or null if all indices have the same type family for the field. /// /// - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Indices { get; init; } /// @@ -51,7 +153,6 @@ public sealed partial class FieldCapability /// Merged metadata across all indices as a map of string keys to arrays of values. A value length of 1 indicates that all indices had the same value for this key, while a length of 2 or more indicates that not all indices had the same value for this key. /// /// - [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } /// @@ -59,7 +160,6 @@ public sealed partial class FieldCapability /// Whether this field is registered as a metadata field. /// /// - [JsonInclude, JsonPropertyName("metadata_field")] public bool? MetadataField { get; init; } /// @@ -67,8 +167,6 @@ public sealed partial class FieldCapability /// The list of indices where this field is not aggregatable, or null if all indices have the same definition for the field. /// /// - [JsonInclude, JsonPropertyName("non_aggregatable_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? NonAggregatableIndices { get; init; } /// @@ -76,8 +174,6 @@ public sealed partial class FieldCapability /// The list of indices where this field is not searchable, or null if all indices have the same definition for the field. /// /// - [JsonInclude, JsonPropertyName("non_searchable_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? NonSearchableIndices { get; init; } /// @@ -85,8 +181,6 @@ public sealed partial class FieldCapability /// Whether this field is indexed for search on all indices. /// /// - [JsonInclude, JsonPropertyName("searchable")] public bool Searchable { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Get/GetResult.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Get/GetResult.g.cs index 10c904ab709..555c101d7f9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Get/GetResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Get/GetResult.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,27 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Get; +internal sealed partial class GetResultConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override GetResult Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFields = default; + LocalJsonProperty propFound = default; + LocalJsonProperty propId = default; + LocalJsonProperty?> propIgnored = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetResult + { + Fields = propFields.Value +, + Found = propFound.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetResult value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetResultConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetResult<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetResultConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetResultConverterFactory))] public sealed partial class GetResult { - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.FieldValues? Fields { get; init; } - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs index 89bfd2d4e2b..a0f872cff3f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,17 +28,85 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.HealthReport; +internal sealed partial class DiagnosisAffectedResourcesConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatureStates = System.Text.Json.JsonEncodedText.Encode("feature_states"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropSlmPolicies = System.Text.Json.JsonEncodedText.Encode("slm_policies"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshotRepositories = System.Text.Json.JsonEncodedText.Encode("snapshot_repositories"); + + public override DiagnosisAffectedResources Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propFeatureStates = default; + LocalJsonProperty?> propIndices = default; + LocalJsonProperty?> propNodes = default; + LocalJsonProperty?> propSlmPolicies = default; + LocalJsonProperty?> propSnapshotRepositories = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureStates.TryRead(ref reader, options, PropFeatureStates)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propSlmPolicies.TryRead(ref reader, options, PropSlmPolicies)) + { + continue; + } + + if (propSnapshotRepositories.TryRead(ref reader, options, PropSnapshotRepositories)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DiagnosisAffectedResources + { + FeatureStates = propFeatureStates.Value +, + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + SlmPolicies = propSlmPolicies.Value +, + SnapshotRepositories = propSnapshotRepositories.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DiagnosisAffectedResources value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureStates, value.FeatureStates); + writer.WriteProperty(options, PropIndices, value.Indices, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropSlmPolicies, value.SlmPolicies); + writer.WriteProperty(options, PropSnapshotRepositories, value.SnapshotRepositories); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DiagnosisAffectedResourcesConverter))] public sealed partial class DiagnosisAffectedResources { - [JsonInclude, JsonPropertyName("feature_states")] public IReadOnlyCollection? FeatureStates { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Indices { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyCollection? Nodes { get; init; } - [JsonInclude, JsonPropertyName("slm_policies")] public IReadOnlyCollection? SlmPolicies { get; init; } - [JsonInclude, JsonPropertyName("snapshot_repositories")] public IReadOnlyCollection? SnapshotRepositories { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MGet/MultiGetOperation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MGet/MultiGetOperation.g.cs index 6621f1f9ef0..68dae62f8e7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MGet/MultiGetOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MGet/MultiGetOperation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,100 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.MGet; +internal sealed partial class MultiGetOperationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MultiGetOperation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiGetOperation + { + Id = propId.Value +, + Index = propIndex.Value +, + Routing = propRouting.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiGetOperation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiGetOperationConverter))] public sealed partial class MultiGetOperation { /// @@ -34,7 +129,6 @@ public sealed partial class MultiGetOperation /// The unique document ID. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Serverless.Id Id { get; set; } /// @@ -42,7 +136,6 @@ public sealed partial class MultiGetOperation /// The index that contains the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; } /// @@ -50,7 +143,6 @@ public sealed partial class MultiGetOperation /// The key for the primary shard the document resides on. Required if routing is used during indexing. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } /// @@ -58,7 +150,6 @@ public sealed partial class MultiGetOperation /// If false, excludes all _source fields. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } /// @@ -66,12 +157,8 @@ public sealed partial class MultiGetOperation /// The stored fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index e3593c503c5..14c9b9c1b3a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,399 +28,336 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.MSearch; -internal sealed partial class MultisearchBodyConverter : JsonConverter +internal sealed partial class MultisearchBodyConverter : System.Text.Json.Serialization.JsonConverter { - public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new MultisearchBody(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override MultisearchBody Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propCollapse = default; + LocalJsonProperty?> propDocvalueFields = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty?> propExt = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty>?> propIndicesBoost = default; + LocalJsonProperty?> propKnn = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propPit = default; + LocalJsonProperty propPostFilter = default; + LocalJsonProperty propProfile = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty?> propRescore = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty?> propSearchAfter = default; + LocalJsonProperty propSeqNoPrimaryTerm = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty?> propStats = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propSuggest = default; + LocalJsonProperty propTerminateAfter = default; + LocalJsonProperty propTimeout = default; + LocalJsonProperty propTrackScores = default; + LocalJsonProperty propTrackTotalHits = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - reader.Read(); - variant.StoredFields = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultisearchBody + { + Aggregations = propAggregations.Value +, + Collapse = propCollapse.Value +, + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Ext = propExt.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + IndicesBoost = propIndicesBoost.Value +, + Knn = propKnn.Value +, + MinScore = propMinScore.Value +, + Pit = propPit.Value +, + PostFilter = propPostFilter.Value +, + Profile = propProfile.Value +, + Query = propQuery.Value +, + Rescore = propRescore.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + SearchAfter = propSearchAfter.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + Stats = propStats.Value +, + StoredFields = propStoredFields.Value +, + Suggest = propSuggest.Value +, + TerminateAfter = propTerminateAfter.Value +, + Timeout = propTimeout.Value +, + TrackScores = propTrackScores.Value +, + TrackTotalHits = propTrackTotalHits.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultisearchBody value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRescore, value.Rescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs index dbff568ba1b..00fb71d5ac7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,35 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.MSearch; +internal sealed partial class MultisearchHeaderConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowNoIndices = System.Text.Json.JsonEncodedText.Encode("allow_no_indices"); + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSearchResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_search_results"); + private static readonly System.Text.Json.JsonEncodedText PropCcsMinimizeRoundtrips = System.Text.Json.JsonEncodedText.Encode("ccs_minimize_roundtrips"); + private static readonly System.Text.Json.JsonEncodedText PropExpandWildcards = System.Text.Json.JsonEncodedText.Encode("expand_wildcards"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreThrottled = System.Text.Json.JsonEncodedText.Encode("ignore_throttled"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnavailable = System.Text.Json.JsonEncodedText.Encode("ignore_unavailable"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropPreference = System.Text.Json.JsonEncodedText.Encode("preference"); + private static readonly System.Text.Json.JsonEncodedText PropRequestCache = System.Text.Json.JsonEncodedText.Encode("request_cache"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSearchType = System.Text.Json.JsonEncodedText.Encode("search_type"); + + public override MultisearchHeader Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowNoIndices = default; + LocalJsonProperty propAllowPartialSearchResults = default; + LocalJsonProperty propCcsMinimizeRoundtrips = default; + LocalJsonProperty?> propExpandWildcards = default; + LocalJsonProperty propIgnoreThrottled = default; + LocalJsonProperty propIgnoreUnavailable = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propPreference = default; + LocalJsonProperty propRequestCache = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSearchType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryRead(ref reader, options, PropAllowNoIndices)) + { + continue; + } + + if (propAllowPartialSearchResults.TryRead(ref reader, options, PropAllowPartialSearchResults)) + { + continue; + } + + if (propCcsMinimizeRoundtrips.TryRead(ref reader, options, PropCcsMinimizeRoundtrips)) + { + continue; + } + + if (propExpandWildcards.TryRead(ref reader, options, PropExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>))) + { + continue; + } + + if (propIgnoreThrottled.TryRead(ref reader, options, PropIgnoreThrottled)) + { + continue; + } + + if (propIgnoreUnavailable.TryRead(ref reader, options, PropIgnoreUnavailable)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propPreference.TryRead(ref reader, options, PropPreference)) + { + continue; + } + + if (propRequestCache.TryRead(ref reader, options, PropRequestCache)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSearchType.TryRead(ref reader, options, PropSearchType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultisearchHeader + { + AllowNoIndices = propAllowNoIndices.Value +, + AllowPartialSearchResults = propAllowPartialSearchResults.Value +, + CcsMinimizeRoundtrips = propCcsMinimizeRoundtrips.Value +, + ExpandWildcards = propExpandWildcards.Value +, + IgnoreThrottled = propIgnoreThrottled.Value +, + IgnoreUnavailable = propIgnoreUnavailable.Value +, + Indices = propIndices.Value +, + Preference = propPreference.Value +, + RequestCache = propRequestCache.Value +, + Routing = propRouting.Value +, + SearchType = propSearchType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultisearchHeader value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowNoIndices, value.AllowNoIndices); + writer.WriteProperty(options, PropAllowPartialSearchResults, value.AllowPartialSearchResults); + writer.WriteProperty(options, PropCcsMinimizeRoundtrips, value.CcsMinimizeRoundtrips); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropPreference, value.Preference); + writer.WriteProperty(options, PropRequestCache, value.RequestCache); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSearchType, value.SearchType); + writer.WriteEndObject(); + } +} + /// /// /// Contains parameters used to limit or change the subsequent search body request. /// /// +[JsonConverter(typeof(MultisearchHeaderConverter))] public sealed partial class MultisearchHeader { - [JsonInclude, JsonPropertyName("allow_no_indices")] public bool? AllowNoIndices { get; set; } - [JsonInclude, JsonPropertyName("allow_partial_search_results")] public bool? AllowPartialSearchResults { get; set; } - [JsonInclude, JsonPropertyName("ccs_minimize_roundtrips")] public bool? CcsMinimizeRoundtrips { get; set; } - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } - [JsonInclude, JsonPropertyName("ignore_throttled")] public bool? IgnoreThrottled { get; set; } - [JsonInclude, JsonPropertyName("ignore_unavailable")] public bool? IgnoreUnavailable { get; set; } - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } - [JsonInclude, JsonPropertyName("preference")] public string? Preference { get; set; } - [JsonInclude, JsonPropertyName("request_cache")] public bool? RequestCache { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } - [JsonInclude, JsonPropertyName("search_type")] public Elastic.Clients.Elasticsearch.Serverless.SearchType? SearchType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs index 1a3667265ba..e241ee14622 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,160 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Mtermvectors; +internal sealed partial class MultiTermVectorsOperationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStatistics = System.Text.Json.JsonEncodedText.Encode("field_statistics"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropOffsets = System.Text.Json.JsonEncodedText.Encode("offsets"); + private static readonly System.Text.Json.JsonEncodedText PropPayloads = System.Text.Json.JsonEncodedText.Encode("payloads"); + private static readonly System.Text.Json.JsonEncodedText PropPositions = System.Text.Json.JsonEncodedText.Encode("positions"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropTermStatistics = System.Text.Json.JsonEncodedText.Encode("term_statistics"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MultiTermVectorsOperation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDoc = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFieldStatistics = default; + LocalJsonProperty propFilter = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propOffsets = default; + LocalJsonProperty propPayloads = default; + LocalJsonProperty propPositions = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propTermStatistics = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFieldStatistics.TryRead(ref reader, options, PropFieldStatistics)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propOffsets.TryRead(ref reader, options, PropOffsets)) + { + continue; + } + + if (propPayloads.TryRead(ref reader, options, PropPayloads)) + { + continue; + } + + if (propPositions.TryRead(ref reader, options, PropPositions)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propTermStatistics.TryRead(ref reader, options, PropTermStatistics)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermVectorsOperation + { + Doc = propDoc.Value +, + Fields = propFields.Value +, + FieldStatistics = propFieldStatistics.Value +, + Filter = propFilter.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Offsets = propOffsets.Value +, + Payloads = propPayloads.Value +, + Positions = propPositions.Value +, + Routing = propRouting.Value +, + TermStatistics = propTermStatistics.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermVectorsOperation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFieldStatistics, value.FieldStatistics); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropOffsets, value.Offsets); + writer.WriteProperty(options, PropPayloads, value.Payloads); + writer.WriteProperty(options, PropPositions, value.Positions); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropTermStatistics, value.TermStatistics); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermVectorsOperationConverter))] public sealed partial class MultiTermVectorsOperation { /// @@ -34,7 +189,6 @@ public sealed partial class MultiTermVectorsOperation /// An artificial document (a document not present in the index) for which you want to retrieve term vectors. /// /// - [JsonInclude, JsonPropertyName("doc")] public object? Doc { get; set; } /// @@ -43,8 +197,6 @@ public sealed partial class MultiTermVectorsOperation /// Used as the default list unless a specific field list is provided in the completion_fields or fielddata_fields parameters. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -52,7 +204,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes the document count, sum of document frequencies, and sum of total term frequencies. /// /// - [JsonInclude, JsonPropertyName("field_statistics")] public bool? FieldStatistics { get; set; } /// @@ -60,7 +211,6 @@ public sealed partial class MultiTermVectorsOperation /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Serverless.Core.TermVectors.Filter? Filter { get; set; } /// @@ -68,7 +218,6 @@ public sealed partial class MultiTermVectorsOperation /// The ID of the document. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Serverless.Id? Id { get; set; } /// @@ -76,7 +225,6 @@ public sealed partial class MultiTermVectorsOperation /// The index of the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; } /// @@ -84,7 +232,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term offsets. /// /// - [JsonInclude, JsonPropertyName("offsets")] public bool? Offsets { get; set; } /// @@ -92,7 +239,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term payloads. /// /// - [JsonInclude, JsonPropertyName("payloads")] public bool? Payloads { get; set; } /// @@ -100,7 +246,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term positions. /// /// - [JsonInclude, JsonPropertyName("positions")] public bool? Positions { get; set; } /// @@ -108,7 +253,6 @@ public sealed partial class MultiTermVectorsOperation /// Custom value used to route operations to a specific shard. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } /// @@ -116,7 +260,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term frequency and document frequency. /// /// - [JsonInclude, JsonPropertyName("term_statistics")] public bool? TermStatistics { get; set; } /// @@ -124,7 +267,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, returns the document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } /// @@ -132,7 +274,6 @@ public sealed partial class MultiTermVectorsOperation /// Specific version type. /// /// - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs index 4f06a813c46..9a1ef2e9bb9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs @@ -38,7 +38,6 @@ public sealed partial class MultiTermVectorsResult [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } [JsonInclude, JsonPropertyName("term_vectors")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.TermVectors.TermVector))] public IReadOnlyDictionary? TermVectors { get; init; } [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs index d3a94bc1579..61885487b62 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,11 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.RankEval; +internal sealed partial class RankEvalQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override RankEvalQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propQuery = default; + LocalJsonProperty propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new RankEvalQuery { Query = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RankEvalQuery + { + Query = propQuery.Value +, + Size = propSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RankEvalQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalQueryConverter))] public sealed partial class RankEvalQuery { - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query Query { get; set; } - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Reindex/Source.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Reindex/Source.g.cs index 7da14332827..bbac23f2f38 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Reindex/Source.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Reindex/Source.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Reindex; +internal sealed partial class SourceConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRemote = System.Text.Json.JsonEncodedText.Encode("remote"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSourceFields = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override Source Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propIndices = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propRemote = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty propSize = default; + LocalJsonProperty propSlice = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propRemote.TryRead(ref reader, options, PropRemote)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + if (propSourceFields.TryRead(ref reader, options, PropSourceFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Source + { + Indices = propIndices.Value +, + Query = propQuery.Value +, + Remote = propRemote.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + Size = propSize.Value +, + Slice = propSlice.Value +, + Sort = propSort.Value +, + SourceFields = propSourceFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Source value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRemote, value.Remote); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SourceConverter))] public sealed partial class Source { /// @@ -35,7 +140,6 @@ public sealed partial class Source /// Accepts a comma-separated list to reindex from multiple sources. /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Serverless.Indices Indices { get; set; } /// @@ -43,7 +147,6 @@ public sealed partial class Source /// Specifies the documents to reindex using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } /// @@ -51,9 +154,7 @@ public sealed partial class Source /// A remote instance of Elasticsearch that you want to index from. /// /// - [JsonInclude, JsonPropertyName("remote")] public Elastic.Clients.Elasticsearch.Serverless.Core.Reindex.RemoteSource? Remote { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -62,7 +163,6 @@ public sealed partial class Source /// Use when indexing from remote to ensure that the batches fit within the on-heap buffer, which defaults to a maximum size of 100 MB. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -70,10 +170,7 @@ public sealed partial class Source /// Slice the reindex request manually using the provided slice ID and total number of slices. /// /// - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.Serverless.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } /// @@ -82,8 +179,6 @@ public sealed partial class Source /// Set to a list to reindex select fields. /// /// - [JsonInclude, JsonPropertyName("_source")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? SourceFields { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionContext.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionContext.g.cs index 735e528d441..557a06cd333 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionContext.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionContext.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class CompletionContextConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropContext = System.Text.Json.JsonEncodedText.Encode("context"); + private static readonly System.Text.Json.JsonEncodedText PropNeighbours = System.Text.Json.JsonEncodedText.Encode("neighbours"); + private static readonly System.Text.Json.JsonEncodedText PropPrecision = System.Text.Json.JsonEncodedText.Encode("precision"); + private static readonly System.Text.Json.JsonEncodedText PropPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + + public override CompletionContext Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propContext = default; + LocalJsonProperty?> propNeighbours = default; + LocalJsonProperty propPrecision = default; + LocalJsonProperty propPrefix = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propContext.TryRead(ref reader, options, PropContext)) + { + continue; + } + + if (propNeighbours.TryRead(ref reader, options, PropNeighbours)) + { + continue; + } + + if (propPrecision.TryRead(ref reader, options, PropPrecision)) + { + continue; + } + + if (propPrefix.TryRead(ref reader, options, PropPrefix)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new CompletionContext { Context = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionContext + { + Boost = propBoost.Value +, + Context = propContext.Value +, + Neighbours = propNeighbours.Value +, + Precision = propPrecision.Value +, + Prefix = propPrefix.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionContext value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropContext, value.Context); + writer.WriteProperty(options, PropNeighbours, value.Neighbours); + writer.WriteProperty(options, PropPrecision, value.Precision); + writer.WriteProperty(options, PropPrefix, value.Prefix); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionContextConverter))] public sealed partial class CompletionContext { /// @@ -35,7 +120,6 @@ public sealed partial class CompletionContext /// The score is computed by multiplying the boost with the suggestion weight. /// /// - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } /// @@ -43,7 +127,6 @@ public sealed partial class CompletionContext /// The value of the category to filter/boost on. /// /// - [JsonInclude, JsonPropertyName("context")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Context Context { get; set; } /// @@ -53,7 +136,6 @@ public sealed partial class CompletionContext /// Defaults to generating neighbors for index time precision level. /// /// - [JsonInclude, JsonPropertyName("neighbours")] public ICollection? Neighbours { get; set; } /// @@ -63,7 +145,6 @@ public sealed partial class CompletionContext /// Defaults to index time precision level. /// /// - [JsonInclude, JsonPropertyName("precision")] public Elastic.Clients.Elasticsearch.Serverless.GeohashPrecision? Precision { get; set; } /// @@ -71,7 +152,6 @@ public sealed partial class CompletionContext /// Whether the category value should be treated as a prefix or not. /// /// - [JsonInclude, JsonPropertyName("prefix")] public bool? Prefix { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggest.g.cs index 2f3b7b91e4c..9e65a310316 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,93 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class CompletionSuggestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override CompletionSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLength = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty>> propOptions = default; + LocalJsonProperty propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker>, Elastic.Clients.Elasticsearch.Serverless.Core.Search.CompletionSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, typeof(SingleOrManyMarker>, Elastic.Clients.Elasticsearch.Serverless.Core.Search.CompletionSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +internal sealed partial class CompletionSuggestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(CompletionSuggest<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(CompletionSuggestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(CompletionSuggestConverterFactory))] public sealed partial class CompletionSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [GenericConverter(typeof(SingleOrManyCollectionConverter<>), unwrap: true)] public IReadOnlyCollection> Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "completion"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs index 822c13b2570..829b9ab9eea 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,27 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class CompletionSuggestOptionConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCollateMatch = System.Text.Json.JsonEncodedText.Encode("collate_match"); + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + private static readonly System.Text.Json.JsonEncodedText PropScore0 = System.Text.Json.JsonEncodedText.Encode("_score"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override CompletionSuggestOption Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCollateMatch = default; + LocalJsonProperty>?> propContexts = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propScore = default; + LocalJsonProperty propScore0 = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollateMatch.TryRead(ref reader, options, PropCollateMatch)) + { + continue; + } + + if (propContexts.TryRead(ref reader, options, PropContexts)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; + } + + if (propScore0.TryRead(ref reader, options, PropScore0)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionSuggestOption + { + CollateMatch = propCollateMatch.Value +, + Contexts = propContexts.Value +, + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Routing = propRouting.Value +, + Score = propScore.Value +, + Score0 = propScore0.Value +, + Source = propSource.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionSuggestOption value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollateMatch, value.CollateMatch); + writer.WriteProperty(options, PropContexts, value.Contexts); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropScore, value.Score); + writer.WriteProperty(options, PropScore0, value.Score0); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +internal sealed partial class CompletionSuggestOptionConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(CompletionSuggestOption<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(CompletionSuggestOptionConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(CompletionSuggestOptionConverterFactory))] public sealed partial class CompletionSuggestOption { - [JsonInclude, JsonPropertyName("collate_match")] public bool? CollateMatch { get; init; } - [JsonInclude, JsonPropertyName("contexts")] public IReadOnlyDictionary>? Contexts { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string? Index { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("score")] public double? Score { get; init; } - [JsonInclude, JsonPropertyName("_score")] public double? Score0 { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldCollapse.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldCollapse.g.cs index a37f32afbc0..3e7601a0206 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldCollapse.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldCollapse.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,9 +28,72 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class FieldCollapseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxConcurrentGroupSearches = System.Text.Json.JsonEncodedText.Encode("max_concurrent_group_searches"); + + public override FieldCollapse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCollapse = default; + LocalJsonProperty propField = default; + LocalJsonProperty?> propInnerHits = default; + LocalJsonProperty propMaxConcurrentGroupSearches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.InnerHits>))) + { + continue; + } + + if (propMaxConcurrentGroupSearches.TryRead(ref reader, options, PropMaxConcurrentGroupSearches)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCollapse + { + Collapse = propCollapse.Value +, + Field = propField.Value +, + InnerHits = propInnerHits.Value +, + MaxConcurrentGroupSearches = propMaxConcurrentGroupSearches.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCollapse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropInnerHits, value.InnerHits, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.Core.Search.InnerHits>)); + writer.WriteProperty(options, PropMaxConcurrentGroupSearches, value.MaxConcurrentGroupSearches); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCollapseConverter))] public sealed partial class FieldCollapse { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -37,7 +101,6 @@ public sealed partial class FieldCollapse /// The field to collapse the result set on /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -45,8 +108,6 @@ public sealed partial class FieldCollapse /// The number of inner hits and their sort order /// /// - [JsonInclude, JsonPropertyName("inner_hits")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.Search.InnerHits))] public ICollection? InnerHits { get; set; } /// @@ -54,7 +115,6 @@ public sealed partial class FieldCollapse /// The number of concurrent requests allowed to retrieve the inner_hits per group /// /// - [JsonInclude, JsonPropertyName("max_concurrent_group_searches")] public int? MaxConcurrentGroupSearches { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldSuggester.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldSuggester.g.cs index c717dbd72ea..bc0b331ed85 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/FieldSuggester.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal FieldSuggester(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal FieldSuggester() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static FieldSuggester Completion(Elastic.Clients.Elasticsearch.Serverless.Core.Search.CompletionSuggester completionSuggester) => new FieldSuggester("completion", completionSuggester); public static FieldSuggester Phrase(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggester phraseSuggester) => new FieldSuggester("phrase", phraseSuggester); @@ -88,121 +93,103 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class FieldSuggesterConverter : JsonConverter +internal sealed partial class FieldSuggesterConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldSuggester Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText PropRegex = System.Text.Json.JsonEncodedText.Encode("regex"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText VariantCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + private static readonly System.Text.Json.JsonEncodedText VariantPhrase = System.Text.Json.JsonEncodedText.Encode("phrase"); + private static readonly System.Text.Json.JsonEncodedText VariantTerm = System.Text.Json.JsonEncodedText.Encode("term"); + + public override FieldSuggester Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propPrefix = default; + LocalJsonProperty propRegex = default; + LocalJsonProperty propText = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - string? prefixValue = default; - string? regexValue = default; - string? textValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propPrefix.TryRead(ref reader, options, PropPrefix)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "prefix") - { - prefixValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "regex") + if (propRegex.TryRead(ref reader, options, PropRegex)) { - regexValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "text") + if (propText.TryRead(ref reader, options, PropText)) { - textValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "completion") + if (reader.ValueTextEquals(VariantCompletion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCompletion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "phrase") + if (reader.ValueTextEquals(VariantPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "term") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FieldSuggester' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new FieldSuggester(variantNameValue, variantValue); - result.Prefix = prefixValue; - result.Regex = regexValue; - result.Text = textValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldSuggester + { + VariantType = variantType, + Variant = variant, + Prefix = propPrefix.Value + , + Regex = propRegex.Value + , + Text = propText.Value + }; } - public override void Write(Utf8JsonWriter writer, FieldSuggester value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSuggester value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Prefix)) + switch (value.VariantType) { - writer.WritePropertyName("prefix"); - writer.WriteStringValue(value.Prefix); - } - - if (!string.IsNullOrEmpty(value.Regex)) - { - writer.WritePropertyName("regex"); - writer.WriteStringValue(value.Regex); - } - - if (!string.IsNullOrEmpty(value.Text)) - { - writer.WritePropertyName("text"); - writer.WriteStringValue(value.Text); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "completion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.CompletionSuggester)value.Variant, options); - break; - case "phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggester)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.TermSuggester)value.Variant, options); - break; - } + case "": + break; + case "completion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.CompletionSuggester?)value.Variant); + break; + case "phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggester?)value.Variant); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.TermSuggester?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FieldSuggester)}'."); } + writer.WriteProperty(options, PropPrefix, value.Prefix); + writer.WriteProperty(options, PropRegex, value.Regex); + writer.WriteProperty(options, PropText, value.Text); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/HighlightField.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/HighlightField.g.cs index 7d5a7e8b08c..473aa62104a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/HighlightField.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/HighlightField.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,250 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class HighlightFieldConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoundaryChars = System.Text.Json.JsonEncodedText.Encode("boundary_chars"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryMaxScan = System.Text.Json.JsonEncodedText.Encode("boundary_max_scan"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryScanner = System.Text.Json.JsonEncodedText.Encode("boundary_scanner"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryScannerLocale = System.Text.Json.JsonEncodedText.Encode("boundary_scanner_locale"); + private static readonly System.Text.Json.JsonEncodedText PropFragmenter = System.Text.Json.JsonEncodedText.Encode("fragmenter"); + private static readonly System.Text.Json.JsonEncodedText PropFragmentOffset = System.Text.Json.JsonEncodedText.Encode("fragment_offset"); + private static readonly System.Text.Json.JsonEncodedText PropFragmentSize = System.Text.Json.JsonEncodedText.Encode("fragment_size"); + private static readonly System.Text.Json.JsonEncodedText PropHighlightFilter = System.Text.Json.JsonEncodedText.Encode("highlight_filter"); + private static readonly System.Text.Json.JsonEncodedText PropHighlightQuery = System.Text.Json.JsonEncodedText.Encode("highlight_query"); + private static readonly System.Text.Json.JsonEncodedText PropMatchedFields = System.Text.Json.JsonEncodedText.Encode("matched_fields"); + private static readonly System.Text.Json.JsonEncodedText PropMaxAnalyzedOffset = System.Text.Json.JsonEncodedText.Encode("max_analyzed_offset"); + private static readonly System.Text.Json.JsonEncodedText PropMaxFragmentLength = System.Text.Json.JsonEncodedText.Encode("max_fragment_length"); + private static readonly System.Text.Json.JsonEncodedText PropNoMatchSize = System.Text.Json.JsonEncodedText.Encode("no_match_size"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfFragments = System.Text.Json.JsonEncodedText.Encode("number_of_fragments"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropPhraseLimit = System.Text.Json.JsonEncodedText.Encode("phrase_limit"); + private static readonly System.Text.Json.JsonEncodedText PropPostTags = System.Text.Json.JsonEncodedText.Encode("post_tags"); + private static readonly System.Text.Json.JsonEncodedText PropPreTags = System.Text.Json.JsonEncodedText.Encode("pre_tags"); + private static readonly System.Text.Json.JsonEncodedText PropRequireFieldMatch = System.Text.Json.JsonEncodedText.Encode("require_field_match"); + private static readonly System.Text.Json.JsonEncodedText PropTagsSchema = System.Text.Json.JsonEncodedText.Encode("tags_schema"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HighlightField Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoundaryChars = default; + LocalJsonProperty propBoundaryMaxScan = default; + LocalJsonProperty propBoundaryScanner = default; + LocalJsonProperty propBoundaryScannerLocale = default; + LocalJsonProperty propFragmenter = default; + LocalJsonProperty propFragmentOffset = default; + LocalJsonProperty propFragmentSize = default; + LocalJsonProperty propHighlightFilter = default; + LocalJsonProperty propHighlightQuery = default; + LocalJsonProperty propMatchedFields = default; + LocalJsonProperty propMaxAnalyzedOffset = default; + LocalJsonProperty propMaxFragmentLength = default; + LocalJsonProperty propNoMatchSize = default; + LocalJsonProperty propNumberOfFragments = default; + LocalJsonProperty?> propOptions = default; + LocalJsonProperty propOrder = default; + LocalJsonProperty propPhraseLimit = default; + LocalJsonProperty?> propPostTags = default; + LocalJsonProperty?> propPreTags = default; + LocalJsonProperty propRequireFieldMatch = default; + LocalJsonProperty propTagsSchema = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoundaryChars.TryRead(ref reader, options, PropBoundaryChars)) + { + continue; + } + + if (propBoundaryMaxScan.TryRead(ref reader, options, PropBoundaryMaxScan)) + { + continue; + } + + if (propBoundaryScanner.TryRead(ref reader, options, PropBoundaryScanner)) + { + continue; + } + + if (propBoundaryScannerLocale.TryRead(ref reader, options, PropBoundaryScannerLocale)) + { + continue; + } + + if (propFragmenter.TryRead(ref reader, options, PropFragmenter)) + { + continue; + } + + if (propFragmentOffset.TryRead(ref reader, options, PropFragmentOffset)) + { + continue; + } + + if (propFragmentSize.TryRead(ref reader, options, PropFragmentSize)) + { + continue; + } + + if (propHighlightFilter.TryRead(ref reader, options, PropHighlightFilter)) + { + continue; + } + + if (propHighlightQuery.TryRead(ref reader, options, PropHighlightQuery)) + { + continue; + } + + if (propMatchedFields.TryRead(ref reader, options, PropMatchedFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMaxAnalyzedOffset.TryRead(ref reader, options, PropMaxAnalyzedOffset)) + { + continue; + } + + if (propMaxFragmentLength.TryRead(ref reader, options, PropMaxFragmentLength)) + { + continue; + } + + if (propNoMatchSize.TryRead(ref reader, options, PropNoMatchSize)) + { + continue; + } + + if (propNumberOfFragments.TryRead(ref reader, options, PropNumberOfFragments)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } + + if (propPhraseLimit.TryRead(ref reader, options, PropPhraseLimit)) + { + continue; + } + + if (propPostTags.TryRead(ref reader, options, PropPostTags)) + { + continue; + } + + if (propPreTags.TryRead(ref reader, options, PropPreTags)) + { + continue; + } + + if (propRequireFieldMatch.TryRead(ref reader, options, PropRequireFieldMatch)) + { + continue; + } + + if (propTagsSchema.TryRead(ref reader, options, PropTagsSchema)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HighlightField + { + BoundaryChars = propBoundaryChars.Value +, + BoundaryMaxScan = propBoundaryMaxScan.Value +, + BoundaryScanner = propBoundaryScanner.Value +, + BoundaryScannerLocale = propBoundaryScannerLocale.Value +, + Fragmenter = propFragmenter.Value +, + FragmentOffset = propFragmentOffset.Value +, + FragmentSize = propFragmentSize.Value +, + HighlightFilter = propHighlightFilter.Value +, + HighlightQuery = propHighlightQuery.Value +, + MatchedFields = propMatchedFields.Value +, + MaxAnalyzedOffset = propMaxAnalyzedOffset.Value +, + MaxFragmentLength = propMaxFragmentLength.Value +, + NoMatchSize = propNoMatchSize.Value +, + NumberOfFragments = propNumberOfFragments.Value +, + Options = propOptions.Value +, + Order = propOrder.Value +, + PhraseLimit = propPhraseLimit.Value +, + PostTags = propPostTags.Value +, + PreTags = propPreTags.Value +, + RequireFieldMatch = propRequireFieldMatch.Value +, + TagsSchema = propTagsSchema.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlightField value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoundaryChars, value.BoundaryChars); + writer.WriteProperty(options, PropBoundaryMaxScan, value.BoundaryMaxScan); + writer.WriteProperty(options, PropBoundaryScanner, value.BoundaryScanner); + writer.WriteProperty(options, PropBoundaryScannerLocale, value.BoundaryScannerLocale); + writer.WriteProperty(options, PropFragmenter, value.Fragmenter); + writer.WriteProperty(options, PropFragmentOffset, value.FragmentOffset); + writer.WriteProperty(options, PropFragmentSize, value.FragmentSize); + writer.WriteProperty(options, PropHighlightFilter, value.HighlightFilter); + writer.WriteProperty(options, PropHighlightQuery, value.HighlightQuery); + writer.WriteProperty(options, PropMatchedFields, value.MatchedFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMaxAnalyzedOffset, value.MaxAnalyzedOffset); + writer.WriteProperty(options, PropMaxFragmentLength, value.MaxFragmentLength); + writer.WriteProperty(options, PropNoMatchSize, value.NoMatchSize); + writer.WriteProperty(options, PropNumberOfFragments, value.NumberOfFragments); + writer.WriteProperty(options, PropOptions, value.Options); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropPhraseLimit, value.PhraseLimit); + writer.WriteProperty(options, PropPostTags, value.PostTags); + writer.WriteProperty(options, PropPreTags, value.PreTags); + writer.WriteProperty(options, PropRequireFieldMatch, value.RequireFieldMatch); + writer.WriteProperty(options, PropTagsSchema, value.TagsSchema); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HighlightFieldConverter))] public sealed partial class HighlightField { /// @@ -34,7 +279,6 @@ public sealed partial class HighlightField /// A string that contains each boundary character. /// /// - [JsonInclude, JsonPropertyName("boundary_chars")] public string? BoundaryChars { get; set; } /// @@ -42,7 +286,6 @@ public sealed partial class HighlightField /// How far to scan for boundary characters. /// /// - [JsonInclude, JsonPropertyName("boundary_max_scan")] public int? BoundaryMaxScan { get; set; } /// @@ -52,7 +295,6 @@ public sealed partial class HighlightField /// Defaults to sentence for the unified highlighter. Defaults to chars for the fvh highlighter. /// /// - [JsonInclude, JsonPropertyName("boundary_scanner")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.BoundaryScanner? BoundaryScanner { get; set; } /// @@ -61,7 +303,6 @@ public sealed partial class HighlightField /// This parameter takes a form of a language tag, for example: "en-US", "fr-FR", "ja-JP". /// /// - [JsonInclude, JsonPropertyName("boundary_scanner_locale")] public string? BoundaryScannerLocale { get; set; } /// @@ -70,9 +311,7 @@ public sealed partial class HighlightField /// Only valid for the plain highlighter. /// /// - [JsonInclude, JsonPropertyName("fragmenter")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlighterFragmenter? Fragmenter { get; set; } - [JsonInclude, JsonPropertyName("fragment_offset")] public int? FragmentOffset { get; set; } /// @@ -80,9 +319,7 @@ public sealed partial class HighlightField /// The size of the highlighted fragment in characters. /// /// - [JsonInclude, JsonPropertyName("fragment_size")] public int? FragmentSize { get; set; } - [JsonInclude, JsonPropertyName("highlight_filter")] public bool? HighlightFilter { get; set; } /// @@ -91,10 +328,7 @@ public sealed partial class HighlightField /// This is especially useful if you use a rescore query because those are not taken into account by highlighting by default. /// /// - [JsonInclude, JsonPropertyName("highlight_query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? HighlightQuery { get; set; } - [JsonInclude, JsonPropertyName("matched_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? MatchedFields { get; set; } /// @@ -104,9 +338,7 @@ public sealed partial class HighlightField /// The max_analyzed_offset query setting does not override the index.highlight.max_analyzed_offset setting, which prevails when it’s set to lower value than the query setting. /// /// - [JsonInclude, JsonPropertyName("max_analyzed_offset")] public int? MaxAnalyzedOffset { get; set; } - [JsonInclude, JsonPropertyName("max_fragment_length")] public int? MaxFragmentLength { get; set; } /// @@ -114,7 +346,6 @@ public sealed partial class HighlightField /// The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight. /// /// - [JsonInclude, JsonPropertyName("no_match_size")] public int? NoMatchSize { get; set; } /// @@ -126,9 +357,7 @@ public sealed partial class HighlightField /// If number_of_fragments is 0, fragment_size is ignored. /// /// - [JsonInclude, JsonPropertyName("number_of_fragments")] public int? NumberOfFragments { get; set; } - [JsonInclude, JsonPropertyName("options")] public IDictionary? Options { get; set; } /// @@ -139,7 +368,6 @@ public sealed partial class HighlightField /// Each highlighter applies its own logic to compute relevancy scores. /// /// - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlighterOrder? Order { get; set; } /// @@ -150,7 +378,6 @@ public sealed partial class HighlightField /// Only supported by the fvh highlighter. /// /// - [JsonInclude, JsonPropertyName("phrase_limit")] public int? PhraseLimit { get; set; } /// @@ -159,7 +386,6 @@ public sealed partial class HighlightField /// By default, highlighted text is wrapped in <em> and </em> tags. /// /// - [JsonInclude, JsonPropertyName("post_tags")] public ICollection? PostTags { get; set; } /// @@ -168,7 +394,6 @@ public sealed partial class HighlightField /// By default, highlighted text is wrapped in <em> and </em> tags. /// /// - [JsonInclude, JsonPropertyName("pre_tags")] public ICollection? PreTags { get; set; } /// @@ -177,7 +402,6 @@ public sealed partial class HighlightField /// Set to false to highlight all fields. /// /// - [JsonInclude, JsonPropertyName("require_field_match")] public bool? RequireFieldMatch { get; set; } /// @@ -185,9 +409,7 @@ public sealed partial class HighlightField /// Set to styled to use the built-in tag schema. /// /// - [JsonInclude, JsonPropertyName("tags_schema")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlighterTagsSchema? TagsSchema { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.HighlighterType? Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Hit.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Hit.g.cs index 4950958526d..ac78cb4a1f5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Hit.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Hit.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,47 +28,267 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class HitConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropExplanation = System.Text.Json.JsonEncodedText.Encode("_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoredFieldValues = System.Text.Json.JsonEncodedText.Encode("ignored_field_values"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText PropMatchedQueries = System.Text.Json.JsonEncodedText.Encode("matched_queries"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("_nested"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("_node"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRank = System.Text.Json.JsonEncodedText.Encode("_rank"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("_score"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShard = System.Text.Json.JsonEncodedText.Encode("_shard"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override Hit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propExplanation = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty>?> propHighlight = default; + LocalJsonProperty propId = default; + LocalJsonProperty?> propIgnored = default; + LocalJsonProperty>?> propIgnoredFieldValues = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propInnerHits = default; + LocalJsonProperty?> propMatchedQueries = default; + LocalJsonProperty propNested = default; + LocalJsonProperty propNode = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propRank = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propScore = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propShard = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryRead(ref reader, options, PropExplanation)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIgnoredFieldValues.TryRead(ref reader, options, PropIgnoredFieldValues)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits)) + { + continue; + } + + if (propMatchedQueries.TryRead(ref reader, options, PropMatchedQueries)) + { + continue; + } + + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRank.TryRead(ref reader, options, PropRank)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShard.TryRead(ref reader, options, PropShard)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Hit + { + Explanation = propExplanation.Value +, + Fields = propFields.Value +, + Highlight = propHighlight.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + IgnoredFieldValues = propIgnoredFieldValues.Value +, + Index = propIndex.Value +, + InnerHits = propInnerHits.Value +, + MatchedQueries = propMatchedQueries.Value +, + Nested = propNested.Value +, + Node = propNode.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Rank = propRank.Value +, + Routing = propRouting.Value +, + Score = propScore.Value +, + SeqNo = propSeqNo.Value +, + Shard = propShard.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Hit value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExplanation, value.Explanation); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIgnoredFieldValues, value.IgnoredFieldValues); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropInnerHits, value.InnerHits); + writer.WriteProperty(options, PropMatchedQueries, value.MatchedQueries); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRank, value.Rank); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropScore, value.Score); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShard, value.Shard); + writer.WriteProperty(options, PropSort, value.Sort); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Hit<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitConverterFactory))] public sealed partial class Hit { - [JsonInclude, JsonPropertyName("_explanation")] public Elastic.Clients.Elasticsearch.Serverless.Core.Explain.Explanation? Explanation { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("highlight")] public IReadOnlyDictionary>? Highlight { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("ignored_field_values")] public IReadOnlyDictionary>? IgnoredFieldValues { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("inner_hits")] public IReadOnlyDictionary? InnerHits { get; init; } - [JsonInclude, JsonPropertyName("matched_queries")] public IReadOnlyCollection? MatchedQueries { get; init; } - [JsonInclude, JsonPropertyName("_nested")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.NestedIdentity? Nested { get; init; } - [JsonInclude, JsonPropertyName("_node")] public string? Node { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_rank")] public int? Rank { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_score")] public double? Score { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shard")] public string? Shard { get; init; } - [JsonInclude, JsonPropertyName("sort")] public IReadOnlyCollection? Sort { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/InnerHits.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/InnerHits.g.cs index 614deb15cec..36045357d6f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/InnerHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/InnerHits.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,16 +28,195 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class InnerHitsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override InnerHits Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCollapse = default; + LocalJsonProperty?> propDocvalueFields = default; + LocalJsonProperty propExplain = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFrom = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propName = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propSeqNoPrimaryTerm = default; + LocalJsonProperty propSize = default; + LocalJsonProperty?> propSort = default; + LocalJsonProperty propSource = default; + LocalJsonProperty propStoredFields = default; + LocalJsonProperty propTrackScores = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } + + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InnerHits + { + Collapse = propCollapse.Value +, + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + Name = propName.Value +, + ScriptFields = propScriptFields.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + TrackScores = propTrackScores.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InnerHits value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InnerHitsConverter))] public sealed partial class InnerHits { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldCollapse? Collapse { get; set; } - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -44,11 +224,8 @@ public sealed partial class InnerHits /// Inner hit starting document offset. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.Highlight? Highlight { get; set; } - [JsonInclude, JsonPropertyName("ignore_unmapped")] public bool? IgnoreUnmapped { get; set; } /// @@ -57,11 +234,8 @@ public sealed partial class InnerHits /// Useful when a search request contains multiple inner hits. /// /// - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.Serverless.Name? Name { get; set; } - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -69,7 +243,6 @@ public sealed partial class InnerHits /// The maximum number of hits to return per inner_hits. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -78,17 +251,10 @@ public sealed partial class InnerHits /// By default, inner hits are sorted by score. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.SortOptions))] public ICollection? Sort { get; set; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.SourceConfig? Source { get; set; } - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/PhraseSuggest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/PhraseSuggest.g.cs index 766f2caf43b..b38cb8b4d77 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/PhraseSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/PhraseSuggest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,76 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class PhraseSuggestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override PhraseSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLength = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty> propOptions = default; + LocalJsonProperty propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PhraseSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhraseSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhraseSuggestConverter))] public sealed partial class PhraseSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.Search.PhraseSuggestOption))] public IReadOnlyCollection Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "phrase"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Rescore.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Rescore.g.cs index a05d61b1266..a8bfc5ba2ac 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Rescore.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Rescore.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Rescore(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Rescore() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Rescore LearningToRank(Elastic.Clients.Elasticsearch.Serverless.Core.Search.LearningToRank learningToRank) => new Rescore("learning_to_rank", learningToRank); public static Rescore Query(Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreQuery rescoreQuery) => new Rescore("query", rescoreQuery); @@ -65,83 +70,71 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RescoreConverter : JsonConverter +internal sealed partial class RescoreConverter : System.Text.Json.Serialization.JsonConverter { - public override Rescore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropWindowSize = System.Text.Json.JsonEncodedText.Encode("window_size"); + private static readonly System.Text.Json.JsonEncodedText VariantLearningToRank = System.Text.Json.JsonEncodedText.Encode("learning_to_rank"); + private static readonly System.Text.Json.JsonEncodedText VariantQuery = System.Text.Json.JsonEncodedText.Encode("query"); - object? variantValue = default; - string? variantNameValue = default; - int? windowSizeValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Rescore Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propWindowSize = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propWindowSize.TryRead(ref reader, options, PropWindowSize)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "window_size") - { - windowSizeValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "learning_to_rank") + if (reader.ValueTextEquals(VariantLearningToRank)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLearningToRank.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "query") + if (reader.ValueTextEquals(VariantQuery)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuery.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Rescore' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Rescore(variantNameValue, variantValue); - result.WindowSize = windowSizeValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Rescore + { + VariantType = variantType, + Variant = variant, + WindowSize = propWindowSize.Value + }; } - public override void Write(Utf8JsonWriter writer, Rescore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Rescore value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.WindowSize.HasValue) - { - writer.WritePropertyName("window_size"); - writer.WriteNumberValue(value.WindowSize.Value); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "learning_to_rank": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LearningToRank)value.Variant, options); - break; - case "query": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreQuery)value.Variant, options); - break; - } + case "": + break; + case "learning_to_rank": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LearningToRank?)value.Variant); + break; + case "query": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.RescoreQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Rescore)}'."); } + writer.WriteProperty(options, PropWindowSize, value.WindowSize); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SmoothingModel.g.cs index f41ccfe7207..32d5f7a5c10 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SmoothingModel.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal SmoothingModel(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SmoothingModel() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SmoothingModel Laplace(Elastic.Clients.Elasticsearch.Serverless.Core.Search.LaplaceSmoothingModel laplaceSmoothingModel) => new SmoothingModel("laplace", laplaceSmoothingModel); public static SmoothingModel LinearInterpolation(Elastic.Clients.Elasticsearch.Serverless.Core.Search.LinearInterpolationSmoothingModel linearInterpolationSmoothingModel) => new SmoothingModel("linear_interpolation", linearInterpolationSmoothingModel); @@ -63,77 +68,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SmoothingModelConverter : JsonConverter +internal sealed partial class SmoothingModelConverter : System.Text.Json.Serialization.JsonConverter { - public override SmoothingModel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantLaplace = System.Text.Json.JsonEncodedText.Encode("laplace"); + private static readonly System.Text.Json.JsonEncodedText VariantLinearInterpolation = System.Text.Json.JsonEncodedText.Encode("linear_interpolation"); + private static readonly System.Text.Json.JsonEncodedText VariantStupidBackoff = System.Text.Json.JsonEncodedText.Encode("stupid_backoff"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override SmoothingModel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantLaplace)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "laplace") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLaplace.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "linear_interpolation") + if (reader.ValueTextEquals(VariantLinearInterpolation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinearInterpolation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stupid_backoff") + if (reader.ValueTextEquals(VariantStupidBackoff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStupidBackoff.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SmoothingModel' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SmoothingModel(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SmoothingModel { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, SmoothingModel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SmoothingModel value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "laplace": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LaplaceSmoothingModel)value.Variant, options); - break; - case "linear_interpolation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LinearInterpolationSmoothingModel)value.Variant, options); - break; - case "stupid_backoff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.StupidBackoffSmoothingModel)value.Variant, options); - break; - } + case "": + break; + case "laplace": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LaplaceSmoothingModel?)value.Variant); + break; + case "linear_interpolation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.LinearInterpolationSmoothingModel?)value.Variant); + break; + case "stupid_backoff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Core.Search.StupidBackoffSmoothingModel?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SmoothingModel)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs index 476fc65d917..3fb3f3f7fa9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,52 +28,57 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; -internal sealed partial class SourceFilterConverter : JsonConverter +internal sealed partial class SourceFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override SourceFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropExcludes = System.Text.Json.JsonEncodedText.Encode("excludes"); + private static readonly System.Text.Json.JsonEncodedText PropExcludes1 = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes = System.Text.Json.JsonEncodedText.Encode("includes"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes1 = System.Text.Json.JsonEncodedText.Encode("include"); + + public override SourceFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SourceFilter(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propExcludes = default; + LocalJsonProperty propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propExcludes.TryRead(ref reader, options, PropExcludes, typeof(SingleOrManyFieldsMarker)) || propExcludes.TryRead(ref reader, options, PropExcludes1, typeof(SingleOrManyFieldsMarker))) { - var property = reader.GetString(); - if (property == "excludes" || property == "exclude") - { - reader.Read(); - variant.Excludes = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } - - if (property == "includes" || property == "include") - { - reader.Read(); - variant.Includes = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } + continue; } - } - return variant; - } + if (propIncludes.TryRead(ref reader, options, PropIncludes, typeof(SingleOrManyFieldsMarker)) || propIncludes.TryRead(ref reader, options, PropIncludes1, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - public override void Write(Utf8JsonWriter writer, SourceFilter value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Excludes is not null) - { - writer.WritePropertyName("excludes"); - new FieldsConverter().Write(writer, value.Excludes, options); + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new SourceFilter { Includes = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } } - if (value.Includes is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SourceFilter { - writer.WritePropertyName("includes"); - new FieldsConverter().Write(writer, value.Includes, options); - } + Excludes = propExcludes.Value +, + Includes = propIncludes.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExcludes, value.Excludes, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIncludes, value.Includes, typeof(SingleOrManyFieldsMarker)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SuggestDictionary.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SuggestDictionary.g.cs index fce42046b43..d24223ecca8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SuggestDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SuggestDictionary.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -33,9 +34,10 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; public partial interface ISuggest { + public string? Type { get; } } -[GenericConverter(typeof(SuggestDictionaryConverter<>), unwrap: true)] +[JsonConverter(typeof(SuggestDictionaryConverterFactory))] public partial class SuggestDictionary : IsAReadOnlyDictionary> { public SuggestDictionary(IReadOnlyDictionary> backingDictionary) : base(backingDictionary) @@ -48,61 +50,87 @@ public SuggestDictionary(IReadOnlyDictionary? TryGet(string key) where T : class, ISuggest => BackingDictionary.TryGetValue(key, out var value) ? value.Cast().ToArray() : null; } -internal sealed partial class SuggestDictionaryConverter : JsonConverter> +internal sealed partial class SuggestDictionaryConverter : System.Text.Json.Serialization.JsonConverter> { - public override SuggestDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override SuggestDictionary Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var dictionary = new Dictionary>(); - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var dictionary = new System.Collections.Generic.Dictionary>(); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); - var name = reader.GetString(); - reader.Read(); - ReadItem(ref reader, options, dictionary, name); + ReadItem(ref reader, options, out string name, out IReadOnlyCollection value); + dictionary[name] = value; } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); return new SuggestDictionary(dictionary); } - public override void Write(Utf8JsonWriter writer, SuggestDictionary value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestDictionary value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SuggestDictionary' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + foreach (var pair in value) + { + WriteItem(writer, options, pair.Key, pair.Value); + } + + writer.WriteEndObject(); } - public static void ReadItem(ref Utf8JsonReader reader, JsonSerializerOptions options, Dictionary> dictionary, string name) + internal static void ReadItem(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, out string name, out IReadOnlyCollection value) { - var nameParts = name.Split('#'); - if (nameParts.Length != 2) - throw new JsonException($"Unable to parse typed-key '{name}'."); - var type = nameParts[0]; - switch (type) + reader.ReadPropertyName(options, out string key); + reader.Read(); + var parts = key.Split('#'); + if (parts.Length != 2) { - case "completion": - { - var item = JsonSerializer.Deserialize>>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "phrase": - { - var item = JsonSerializer.Deserialize>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + throw new System.Text.Json.JsonException($"Unable to parse typed-key '{key}' for variant '{nameof(IReadOnlyCollection)}'."); + } - case "term": - { - var item = JsonSerializer.Deserialize>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + var discriminator = parts[0]; + name = parts[1]; + value = discriminator switch + { + "completion" => reader.ReadValue>>(options), + "phrase" => reader.ReadValue>(options), + "term" => reader.ReadValue>(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IReadOnlyCollection)}'.") + }; + } + internal static void WriteItem(System.Text.Json.Utf8JsonWriter writer, System.Text.Json.JsonSerializerOptions options, string name, IReadOnlyCollection value) + { + var key = value.First().Type + '#' + name; + switch (value) + { + case IReadOnlyCollection> v: + writer.WriteProperty(options, key, v); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v); + break; default: - throw new NotSupportedException($"The tagged variant '{type}' is currently not supported."); + throw new System.Text.Json.JsonException($"Variant '{0}' is not supported for type '{nameof(IReadOnlyCollection)}'."); } } +} + +internal sealed partial class SuggestDictionaryConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SuggestDictionary<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SuggestDictionaryConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Suggester.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Suggester.g.cs index 7f1dbc2d2f9..1fbf0b220e3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Suggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/Suggester.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,53 +28,49 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; -internal sealed partial class SuggesterConverter : JsonConverter +internal sealed partial class SuggesterConverter : System.Text.Json.Serialization.JsonConverter { - public override Suggester Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropSuggesters = System.Text.Json.JsonEncodedText.Encode("suggesters"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override Suggester Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new Suggester(); - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propSuggesters = default; + LocalJsonProperty propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propText.TryRead(ref reader, options, PropText)) { - var property = reader.GetString(); - if (property == "text") - { - variant.Text = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + propSuggesters ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out Elastic.Clients.Elasticsearch.Serverless.Core.Search.FieldSuggester value); + propSuggesters[key] = value; } - variant.Suggesters = additionalProperties; - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Suggester + { + Suggesters = propSuggesters +, + Text = propText.Value + }; } - public override void Write(Utf8JsonWriter writer, Suggester value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Suggester value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); + writer.WriteProperty(options, PropText, value.Text); if (value.Suggesters is not null) { - foreach (var additionalProperty in value.Suggesters) + foreach (var item in value.Suggesters) { - writer.WritePropertyName(additionalProperty.Key); - JsonSerializer.Serialize(writer, additionalProperty.Value, options); + writer.WriteProperty(options, item.Key, item.Value); } } - if (!string.IsNullOrEmpty(value.Text)) - { - writer.WritePropertyName("text"); - writer.WriteStringValue(value.Text); - } - writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/TermSuggest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/TermSuggest.g.cs index 3f8e3ff522c..f56f9eca800 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/TermSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/TermSuggest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,76 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Core.Search; +internal sealed partial class TermSuggestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override TermSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propLength = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty> propOptions = default; + LocalJsonProperty propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Core.Search.TermSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.Core.Search.TermSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermSuggestConverter))] public sealed partial class TermSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.Core.Search.TermSuggestOption))] public IReadOnlyCollection Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "term"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enrich/EnrichPolicy.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enrich/EnrichPolicy.g.cs index fdac64dac40..5500284fe36 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enrich/EnrichPolicy.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enrich/EnrichPolicy.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,20 +28,97 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Enrich; +internal sealed partial class EnrichPolicyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropElasticsearchVersion = System.Text.Json.JsonEncodedText.Encode("elasticsearch_version"); + private static readonly System.Text.Json.JsonEncodedText PropEnrichFields = System.Text.Json.JsonEncodedText.Encode("enrich_fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMatchField = System.Text.Json.JsonEncodedText.Encode("match_field"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + + public override EnrichPolicy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propElasticsearchVersion = default; + LocalJsonProperty propEnrichFields = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propMatchField = default; + LocalJsonProperty propName = default; + LocalJsonProperty propQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propElasticsearchVersion.TryRead(ref reader, options, PropElasticsearchVersion)) + { + continue; + } + + if (propEnrichFields.TryRead(ref reader, options, PropEnrichFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propMatchField.TryRead(ref reader, options, PropMatchField)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrichPolicy + { + ElasticsearchVersion = propElasticsearchVersion.Value +, + EnrichFields = propEnrichFields.Value +, + Indices = propIndices.Value +, + MatchField = propMatchField.Value +, + Name = propName.Value +, + Query = propQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichPolicy value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropElasticsearchVersion, value.ElasticsearchVersion); + writer.WriteProperty(options, PropEnrichFields, value.EnrichFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropMatchField, value.MatchField); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrichPolicyConverter))] public sealed partial class EnrichPolicy { - [JsonInclude, JsonPropertyName("elasticsearch_version")] public string? ElasticsearchVersion { get; set; } - [JsonInclude, JsonPropertyName("enrich_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields EnrichFields { get; set; } - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Indices Indices { get; set; } - [JsonInclude, JsonPropertyName("match_field")] public Elastic.Clients.Elasticsearch.Serverless.Field MatchField { get; set; } - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.Serverless.Name? Name { get; set; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Aggregations.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Aggregations.g.cs index a60560bba8e..d155b3767e8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Aggregations.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Aggregations.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -49,74 +50,102 @@ public enum CalendarInterval Day } -internal sealed class CalendarIntervalConverter : JsonConverter +internal sealed partial class CalendarIntervalConverter : System.Text.Json.Serialization.JsonConverter { - public override CalendarInterval Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYear = System.Text.Json.JsonEncodedText.Encode("year"); + private static readonly System.Text.Json.JsonEncodedText MemberYear1 = System.Text.Json.JsonEncodedText.Encode("1y"); + private static readonly System.Text.Json.JsonEncodedText MemberWeek = System.Text.Json.JsonEncodedText.Encode("week"); + private static readonly System.Text.Json.JsonEncodedText MemberWeek1 = System.Text.Json.JsonEncodedText.Encode("1w"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond1 = System.Text.Json.JsonEncodedText.Encode("1s"); + private static readonly System.Text.Json.JsonEncodedText MemberQuarter = System.Text.Json.JsonEncodedText.Encode("quarter"); + private static readonly System.Text.Json.JsonEncodedText MemberQuarter1 = System.Text.Json.JsonEncodedText.Encode("1q"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth = System.Text.Json.JsonEncodedText.Encode("month"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth1 = System.Text.Json.JsonEncodedText.Encode("1M"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute = System.Text.Json.JsonEncodedText.Encode("minute"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute1 = System.Text.Json.JsonEncodedText.Encode("1m"); + private static readonly System.Text.Json.JsonEncodedText MemberHour = System.Text.Json.JsonEncodedText.Encode("hour"); + private static readonly System.Text.Json.JsonEncodedText MemberHour1 = System.Text.Json.JsonEncodedText.Encode("1h"); + private static readonly System.Text.Json.JsonEncodedText MemberDay = System.Text.Json.JsonEncodedText.Encode("day"); + private static readonly System.Text.Json.JsonEncodedText MemberDay1 = System.Text.Json.JsonEncodedText.Encode("1d"); + + public override CalendarInterval Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "year": - case "1y": - return CalendarInterval.Year; - case "week": - case "1w": - return CalendarInterval.Week; - case "second": - case "1s": - return CalendarInterval.Second; - case "quarter": - case "1q": - return CalendarInterval.Quarter; - case "month": - case "1M": - return CalendarInterval.Month; - case "minute": - case "1m": - return CalendarInterval.Minute; - case "hour": - case "1h": - return CalendarInterval.Hour; - case "day": - case "1d": - return CalendarInterval.Day; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYear) || reader.ValueTextEquals(MemberYear1)) + { + return CalendarInterval.Year; + } + + if (reader.ValueTextEquals(MemberWeek) || reader.ValueTextEquals(MemberWeek1)) + { + return CalendarInterval.Week; + } + + if (reader.ValueTextEquals(MemberSecond) || reader.ValueTextEquals(MemberSecond1)) + { + return CalendarInterval.Second; + } + + if (reader.ValueTextEquals(MemberQuarter) || reader.ValueTextEquals(MemberQuarter1)) + { + return CalendarInterval.Quarter; + } + + if (reader.ValueTextEquals(MemberMonth) || reader.ValueTextEquals(MemberMonth1)) + { + return CalendarInterval.Month; + } + + if (reader.ValueTextEquals(MemberMinute) || reader.ValueTextEquals(MemberMinute1)) + { + return CalendarInterval.Minute; + } + + if (reader.ValueTextEquals(MemberHour) || reader.ValueTextEquals(MemberHour1)) + { + return CalendarInterval.Hour; + } + + if (reader.ValueTextEquals(MemberDay) || reader.ValueTextEquals(MemberDay1)) + { + return CalendarInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CalendarInterval)}'."); } - public override void Write(Utf8JsonWriter writer, CalendarInterval value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CalendarInterval value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CalendarInterval.Year: - writer.WriteStringValue("year"); - return; + writer.WriteStringValue(MemberYear); + break; case CalendarInterval.Week: - writer.WriteStringValue("week"); - return; + writer.WriteStringValue(MemberWeek); + break; case CalendarInterval.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case CalendarInterval.Quarter: - writer.WriteStringValue("quarter"); - return; + writer.WriteStringValue(MemberQuarter); + break; case CalendarInterval.Month: - writer.WriteStringValue("month"); - return; + writer.WriteStringValue(MemberMonth); + break; case CalendarInterval.Minute: - writer.WriteStringValue("minute"); - return; + writer.WriteStringValue(MemberMinute); + break; case CalendarInterval.Hour: - writer.WriteStringValue("hour"); - return; + writer.WriteStringValue(MemberHour); + break; case CalendarInterval.Day: - writer.WriteStringValue("day"); - return; + writer.WriteStringValue(MemberDay); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CalendarInterval)}'."); } - - writer.WriteNullValue(); } } @@ -160,51 +189,67 @@ public enum CardinalityExecutionMode Direct } -internal sealed class CardinalityExecutionModeConverter : JsonConverter +internal sealed partial class CardinalityExecutionModeConverter : System.Text.Json.Serialization.JsonConverter { - public override CardinalityExecutionMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSegmentOrdinals = System.Text.Json.JsonEncodedText.Encode("segment_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberSaveTimeHeuristic = System.Text.Json.JsonEncodedText.Encode("save_time_heuristic"); + private static readonly System.Text.Json.JsonEncodedText MemberSaveMemoryHeuristic = System.Text.Json.JsonEncodedText.Encode("save_memory_heuristic"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberDirect = System.Text.Json.JsonEncodedText.Encode("direct"); + + public override CardinalityExecutionMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "segment_ordinals": - return CardinalityExecutionMode.SegmentOrdinals; - case "save_time_heuristic": - return CardinalityExecutionMode.SaveTimeHeuristic; - case "save_memory_heuristic": - return CardinalityExecutionMode.SaveMemoryHeuristic; - case "global_ordinals": - return CardinalityExecutionMode.GlobalOrdinals; - case "direct": - return CardinalityExecutionMode.Direct; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSegmentOrdinals)) + { + return CardinalityExecutionMode.SegmentOrdinals; + } + + if (reader.ValueTextEquals(MemberSaveTimeHeuristic)) + { + return CardinalityExecutionMode.SaveTimeHeuristic; + } + + if (reader.ValueTextEquals(MemberSaveMemoryHeuristic)) + { + return CardinalityExecutionMode.SaveMemoryHeuristic; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinals)) + { + return CardinalityExecutionMode.GlobalOrdinals; + } + + if (reader.ValueTextEquals(MemberDirect)) + { + return CardinalityExecutionMode.Direct; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CardinalityExecutionMode)}'."); } - public override void Write(Utf8JsonWriter writer, CardinalityExecutionMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CardinalityExecutionMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CardinalityExecutionMode.SegmentOrdinals: - writer.WriteStringValue("segment_ordinals"); - return; + writer.WriteStringValue(MemberSegmentOrdinals); + break; case CardinalityExecutionMode.SaveTimeHeuristic: - writer.WriteStringValue("save_time_heuristic"); - return; + writer.WriteStringValue(MemberSaveTimeHeuristic); + break; case CardinalityExecutionMode.SaveMemoryHeuristic: - writer.WriteStringValue("save_memory_heuristic"); - return; + writer.WriteStringValue(MemberSaveMemoryHeuristic); + break; case CardinalityExecutionMode.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; case CardinalityExecutionMode.Direct: - writer.WriteStringValue("direct"); - return; + writer.WriteStringValue(MemberDirect); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CardinalityExecutionMode)}'."); } - - writer.WriteNullValue(); } } @@ -236,41 +281,49 @@ public enum GapPolicy InsertZeros } -internal sealed class GapPolicyConverter : JsonConverter +internal sealed partial class GapPolicyConverter : System.Text.Json.Serialization.JsonConverter { - public override GapPolicy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSkip = System.Text.Json.JsonEncodedText.Encode("skip"); + private static readonly System.Text.Json.JsonEncodedText MemberKeepValues = System.Text.Json.JsonEncodedText.Encode("keep_values"); + private static readonly System.Text.Json.JsonEncodedText MemberInsertZeros = System.Text.Json.JsonEncodedText.Encode("insert_zeros"); + + public override GapPolicy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSkip)) + { + return GapPolicy.Skip; + } + + if (reader.ValueTextEquals(MemberKeepValues)) { - case "skip": - return GapPolicy.Skip; - case "keep_values": - return GapPolicy.KeepValues; - case "insert_zeros": - return GapPolicy.InsertZeros; + return GapPolicy.KeepValues; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberInsertZeros)) + { + return GapPolicy.InsertZeros; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GapPolicy)}'."); } - public override void Write(Utf8JsonWriter writer, GapPolicy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GapPolicy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GapPolicy.Skip: - writer.WriteStringValue("skip"); - return; + writer.WriteStringValue(MemberSkip); + break; case GapPolicy.KeepValues: - writer.WriteStringValue("keep_values"); - return; + writer.WriteStringValue(MemberKeepValues); + break; case GapPolicy.InsertZeros: - writer.WriteStringValue("insert_zeros"); - return; + writer.WriteStringValue(MemberInsertZeros); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GapPolicy)}'."); } - - writer.WriteNullValue(); } } @@ -291,56 +344,76 @@ public enum MinimumInterval Day } -internal sealed class MinimumIntervalConverter : JsonConverter +internal sealed partial class MinimumIntervalConverter : System.Text.Json.Serialization.JsonConverter { - public override MinimumInterval Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYear = System.Text.Json.JsonEncodedText.Encode("year"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth = System.Text.Json.JsonEncodedText.Encode("month"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute = System.Text.Json.JsonEncodedText.Encode("minute"); + private static readonly System.Text.Json.JsonEncodedText MemberHour = System.Text.Json.JsonEncodedText.Encode("hour"); + private static readonly System.Text.Json.JsonEncodedText MemberDay = System.Text.Json.JsonEncodedText.Encode("day"); + + public override MinimumInterval Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "year": - return MinimumInterval.Year; - case "second": - return MinimumInterval.Second; - case "month": - return MinimumInterval.Month; - case "minute": - return MinimumInterval.Minute; - case "hour": - return MinimumInterval.Hour; - case "day": - return MinimumInterval.Day; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYear)) + { + return MinimumInterval.Year; + } + + if (reader.ValueTextEquals(MemberSecond)) + { + return MinimumInterval.Second; + } + + if (reader.ValueTextEquals(MemberMonth)) + { + return MinimumInterval.Month; + } + + if (reader.ValueTextEquals(MemberMinute)) + { + return MinimumInterval.Minute; + } + + if (reader.ValueTextEquals(MemberHour)) + { + return MinimumInterval.Hour; + } + + if (reader.ValueTextEquals(MemberDay)) + { + return MinimumInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MinimumInterval)}'."); } - public override void Write(Utf8JsonWriter writer, MinimumInterval value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MinimumInterval value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MinimumInterval.Year: - writer.WriteStringValue("year"); - return; + writer.WriteStringValue(MemberYear); + break; case MinimumInterval.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case MinimumInterval.Month: - writer.WriteStringValue("month"); - return; + writer.WriteStringValue(MemberMonth); + break; case MinimumInterval.Minute: - writer.WriteStringValue("minute"); - return; + writer.WriteStringValue(MemberMinute); + break; case MinimumInterval.Hour: - writer.WriteStringValue("hour"); - return; + writer.WriteStringValue(MemberHour); + break; case MinimumInterval.Day: - writer.WriteStringValue("day"); - return; + writer.WriteStringValue(MemberDay); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MinimumInterval)}'."); } - - writer.WriteNullValue(); } } @@ -355,41 +428,49 @@ public enum MissingOrder Default } -internal sealed class MissingOrderConverter : JsonConverter +internal sealed partial class MissingOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override MissingOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLast = System.Text.Json.JsonEncodedText.Encode("last"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + private static readonly System.Text.Json.JsonEncodedText MemberDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override MissingOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLast)) { - case "last": - return MissingOrder.Last; - case "first": - return MissingOrder.First; - case "default": - return MissingOrder.Default; + return MissingOrder.Last; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFirst)) + { + return MissingOrder.First; + } + + if (reader.ValueTextEquals(MemberDefault)) + { + return MissingOrder.Default; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MissingOrder)}'."); } - public override void Write(Utf8JsonWriter writer, MissingOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MissingOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MissingOrder.Last: - writer.WriteStringValue("last"); - return; + writer.WriteStringValue(MemberLast); + break; case MissingOrder.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; case MissingOrder.Default: - writer.WriteStringValue("default"); - return; + writer.WriteStringValue(MemberDefault); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MissingOrder)}'."); } - - writer.WriteNullValue(); } } @@ -440,56 +521,76 @@ public enum NormalizeMethod Mean } -internal sealed class NormalizeMethodConverter : JsonConverter +internal sealed partial class NormalizeMethodConverter : System.Text.Json.Serialization.JsonConverter { - public override NormalizeMethod Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberZScore = System.Text.Json.JsonEncodedText.Encode("z-score"); + private static readonly System.Text.Json.JsonEncodedText MemberSoftmax = System.Text.Json.JsonEncodedText.Encode("softmax"); + private static readonly System.Text.Json.JsonEncodedText MemberRescale0100 = System.Text.Json.JsonEncodedText.Encode("rescale_0_100"); + private static readonly System.Text.Json.JsonEncodedText MemberRescale01 = System.Text.Json.JsonEncodedText.Encode("rescale_0_1"); + private static readonly System.Text.Json.JsonEncodedText MemberPercentOfSum = System.Text.Json.JsonEncodedText.Encode("percent_of_sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMean = System.Text.Json.JsonEncodedText.Encode("mean"); + + public override NormalizeMethod Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "z-score": - return NormalizeMethod.ZScore; - case "softmax": - return NormalizeMethod.Softmax; - case "rescale_0_100": - return NormalizeMethod.Rescale0100; - case "rescale_0_1": - return NormalizeMethod.Rescale01; - case "percent_of_sum": - return NormalizeMethod.PercentOfSum; - case "mean": - return NormalizeMethod.Mean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberZScore)) + { + return NormalizeMethod.ZScore; + } + + if (reader.ValueTextEquals(MemberSoftmax)) + { + return NormalizeMethod.Softmax; + } + + if (reader.ValueTextEquals(MemberRescale0100)) + { + return NormalizeMethod.Rescale0100; + } + + if (reader.ValueTextEquals(MemberRescale01)) + { + return NormalizeMethod.Rescale01; + } + + if (reader.ValueTextEquals(MemberPercentOfSum)) + { + return NormalizeMethod.PercentOfSum; + } + + if (reader.ValueTextEquals(MemberMean)) + { + return NormalizeMethod.Mean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NormalizeMethod)}'."); } - public override void Write(Utf8JsonWriter writer, NormalizeMethod value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NormalizeMethod value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NormalizeMethod.ZScore: - writer.WriteStringValue("z-score"); - return; + writer.WriteStringValue(MemberZScore); + break; case NormalizeMethod.Softmax: - writer.WriteStringValue("softmax"); - return; + writer.WriteStringValue(MemberSoftmax); + break; case NormalizeMethod.Rescale0100: - writer.WriteStringValue("rescale_0_100"); - return; + writer.WriteStringValue(MemberRescale0100); + break; case NormalizeMethod.Rescale01: - writer.WriteStringValue("rescale_0_1"); - return; + writer.WriteStringValue(MemberRescale01); + break; case NormalizeMethod.PercentOfSum: - writer.WriteStringValue("percent_of_sum"); - return; + writer.WriteStringValue(MemberPercentOfSum); + break; case NormalizeMethod.Mean: - writer.WriteStringValue("mean"); - return; + writer.WriteStringValue(MemberMean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NormalizeMethod)}'."); } - - writer.WriteNullValue(); } } @@ -512,36 +613,40 @@ public enum RateMode Sum } -internal sealed class RateModeConverter : JsonConverter +internal sealed partial class RateModeConverter : System.Text.Json.Serialization.JsonConverter { - public override RateMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberValueCount = System.Text.Json.JsonEncodedText.Encode("value_count"); + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + + public override RateMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberValueCount)) { - case "value_count": - return RateMode.ValueCount; - case "sum": - return RateMode.Sum; + return RateMode.ValueCount; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSum)) + { + return RateMode.Sum; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RateMode)}'."); } - public override void Write(Utf8JsonWriter writer, RateMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RateMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RateMode.ValueCount: - writer.WriteStringValue("value_count"); - return; + writer.WriteStringValue(MemberValueCount); + break; case RateMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RateMode)}'."); } - - writer.WriteNullValue(); } } @@ -571,41 +676,49 @@ public enum SamplerAggregationExecutionHint BytesHash } -internal sealed class SamplerAggregationExecutionHintConverter : JsonConverter +internal sealed partial class SamplerAggregationExecutionHintConverter : System.Text.Json.Serialization.JsonConverter { - public override SamplerAggregationExecutionHint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMap = System.Text.Json.JsonEncodedText.Encode("map"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberBytesHash = System.Text.Json.JsonEncodedText.Encode("bytes_hash"); + + public override SamplerAggregationExecutionHint Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMap)) { - case "map": - return SamplerAggregationExecutionHint.Map; - case "global_ordinals": - return SamplerAggregationExecutionHint.GlobalOrdinals; - case "bytes_hash": - return SamplerAggregationExecutionHint.BytesHash; + return SamplerAggregationExecutionHint.Map; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGlobalOrdinals)) + { + return SamplerAggregationExecutionHint.GlobalOrdinals; + } + + if (reader.ValueTextEquals(MemberBytesHash)) + { + return SamplerAggregationExecutionHint.BytesHash; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SamplerAggregationExecutionHint)}'."); } - public override void Write(Utf8JsonWriter writer, SamplerAggregationExecutionHint value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamplerAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SamplerAggregationExecutionHint.Map: - writer.WriteStringValue("map"); - return; + writer.WriteStringValue(MemberMap); + break; case SamplerAggregationExecutionHint.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; case SamplerAggregationExecutionHint.BytesHash: - writer.WriteStringValue("bytes_hash"); - return; + writer.WriteStringValue(MemberBytesHash); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SamplerAggregationExecutionHint)}'."); } - - writer.WriteNullValue(); } } @@ -628,36 +741,40 @@ public enum TermsAggregationCollectMode BreadthFirst } -internal sealed class TermsAggregationCollectModeConverter : JsonConverter +internal sealed partial class TermsAggregationCollectModeConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsAggregationCollectMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDepthFirst = System.Text.Json.JsonEncodedText.Encode("depth_first"); + private static readonly System.Text.Json.JsonEncodedText MemberBreadthFirst = System.Text.Json.JsonEncodedText.Encode("breadth_first"); + + public override TermsAggregationCollectMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDepthFirst)) + { + return TermsAggregationCollectMode.DepthFirst; + } + + if (reader.ValueTextEquals(MemberBreadthFirst)) { - case "depth_first": - return TermsAggregationCollectMode.DepthFirst; - case "breadth_first": - return TermsAggregationCollectMode.BreadthFirst; + return TermsAggregationCollectMode.BreadthFirst; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermsAggregationCollectMode)}'."); } - public override void Write(Utf8JsonWriter writer, TermsAggregationCollectMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregationCollectMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermsAggregationCollectMode.DepthFirst: - writer.WriteStringValue("depth_first"); - return; + writer.WriteStringValue(MemberDepthFirst); + break; case TermsAggregationCollectMode.BreadthFirst: - writer.WriteStringValue("breadth_first"); - return; + writer.WriteStringValue(MemberBreadthFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermsAggregationCollectMode)}'."); } - - writer.WriteNullValue(); } } @@ -674,46 +791,58 @@ public enum TermsAggregationExecutionHint GlobalOrdinals } -internal sealed class TermsAggregationExecutionHintConverter : JsonConverter +internal sealed partial class TermsAggregationExecutionHintConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsAggregationExecutionHint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMap = System.Text.Json.JsonEncodedText.Encode("map"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinalsLowCardinality = System.Text.Json.JsonEncodedText.Encode("global_ordinals_low_cardinality"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinalsHash = System.Text.Json.JsonEncodedText.Encode("global_ordinals_hash"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + + public override TermsAggregationExecutionHint Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMap)) + { + return TermsAggregationExecutionHint.Map; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinalsLowCardinality)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinalsHash)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsHash; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinals)) { - case "map": - return TermsAggregationExecutionHint.Map; - case "global_ordinals_low_cardinality": - return TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality; - case "global_ordinals_hash": - return TermsAggregationExecutionHint.GlobalOrdinalsHash; - case "global_ordinals": - return TermsAggregationExecutionHint.GlobalOrdinals; + return TermsAggregationExecutionHint.GlobalOrdinals; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermsAggregationExecutionHint)}'."); } - public override void Write(Utf8JsonWriter writer, TermsAggregationExecutionHint value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermsAggregationExecutionHint.Map: - writer.WriteStringValue("map"); - return; + writer.WriteStringValue(MemberMap); + break; case TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality: - writer.WriteStringValue("global_ordinals_low_cardinality"); - return; + writer.WriteStringValue(MemberGlobalOrdinalsLowCardinality); + break; case TermsAggregationExecutionHint.GlobalOrdinalsHash: - writer.WriteStringValue("global_ordinals_hash"); - return; + writer.WriteStringValue(MemberGlobalOrdinalsHash); + break; case TermsAggregationExecutionHint.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermsAggregationExecutionHint)}'."); } - - writer.WriteNullValue(); } } @@ -743,41 +872,49 @@ public enum TTestType Heteroscedastic } -internal sealed class TTestTypeConverter : JsonConverter +internal sealed partial class TTestTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TTestType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPaired = System.Text.Json.JsonEncodedText.Encode("paired"); + private static readonly System.Text.Json.JsonEncodedText MemberHomoscedastic = System.Text.Json.JsonEncodedText.Encode("homoscedastic"); + private static readonly System.Text.Json.JsonEncodedText MemberHeteroscedastic = System.Text.Json.JsonEncodedText.Encode("heteroscedastic"); + + public override TTestType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPaired)) + { + return TTestType.Paired; + } + + if (reader.ValueTextEquals(MemberHomoscedastic)) { - case "paired": - return TTestType.Paired; - case "homoscedastic": - return TTestType.Homoscedastic; - case "heteroscedastic": - return TTestType.Heteroscedastic; + return TTestType.Homoscedastic; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberHeteroscedastic)) + { + return TTestType.Heteroscedastic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TTestType)}'."); } - public override void Write(Utf8JsonWriter writer, TTestType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TTestType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TTestType.Paired: - writer.WriteStringValue("paired"); - return; + writer.WriteStringValue(MemberPaired); + break; case TTestType.Homoscedastic: - writer.WriteStringValue("homoscedastic"); - return; + writer.WriteStringValue(MemberHomoscedastic); + break; case TTestType.Heteroscedastic: - writer.WriteStringValue("heteroscedastic"); - return; + writer.WriteStringValue(MemberHeteroscedastic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TTestType)}'."); } - - writer.WriteNullValue(); } } @@ -806,75 +943,111 @@ public enum ValueType Boolean } -internal sealed class ValueTypeConverter : JsonConverter +internal sealed partial class ValueTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ValueType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberNumeric = System.Text.Json.JsonEncodedText.Encode("numeric"); + private static readonly System.Text.Json.JsonEncodedText MemberNumber = System.Text.Json.JsonEncodedText.Encode("number"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + + public override ValueType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "string": - return ValueType.String; - case "numeric": - return ValueType.Numeric; - case "number": - return ValueType.Number; - case "long": - return ValueType.Long; - case "ip": - return ValueType.Ip; - case "geo_point": - return ValueType.GeoPoint; - case "double": - return ValueType.Double; - case "date_nanos": - return ValueType.DateNanos; - case "date": - return ValueType.Date; - case "boolean": - return ValueType.Boolean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) + { + return ValueType.String; + } + + if (reader.ValueTextEquals(MemberNumeric)) + { + return ValueType.Numeric; + } + + if (reader.ValueTextEquals(MemberNumber)) + { + return ValueType.Number; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return ValueType.Long; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return ValueType.Ip; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return ValueType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return ValueType.Double; + } + + if (reader.ValueTextEquals(MemberDateNanos)) + { + return ValueType.DateNanos; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return ValueType.Date; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return ValueType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ValueType)}'."); } - public override void Write(Utf8JsonWriter writer, ValueType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValueType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ValueType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ValueType.Numeric: - writer.WriteStringValue("numeric"); - return; + writer.WriteStringValue(MemberNumeric); + break; case ValueType.Number: - writer.WriteStringValue("number"); - return; + writer.WriteStringValue(MemberNumber); + break; case ValueType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case ValueType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case ValueType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case ValueType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case ValueType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case ValueType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case ValueType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ValueType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Analysis.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Analysis.g.cs index 3cc97f3f7a2..6e69ac8d730 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Analysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Analysis.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -39,41 +40,49 @@ public enum DelimitedPayloadEncoding Float } -internal sealed class DelimitedPayloadEncodingConverter : JsonConverter +internal sealed partial class DelimitedPayloadEncodingConverter : System.Text.Json.Serialization.JsonConverter { - public override DelimitedPayloadEncoding Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("int"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentity = System.Text.Json.JsonEncodedText.Encode("identity"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + + public override DelimitedPayloadEncoding Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInteger)) + { + return DelimitedPayloadEncoding.Integer; + } + + if (reader.ValueTextEquals(MemberIdentity)) + { + return DelimitedPayloadEncoding.Identity; + } + + if (reader.ValueTextEquals(MemberFloat)) { - case "int": - return DelimitedPayloadEncoding.Integer; - case "identity": - return DelimitedPayloadEncoding.Identity; - case "float": - return DelimitedPayloadEncoding.Float; + return DelimitedPayloadEncoding.Float; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DelimitedPayloadEncoding)}'."); } - public override void Write(Utf8JsonWriter writer, DelimitedPayloadEncoding value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DelimitedPayloadEncoding value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DelimitedPayloadEncoding.Integer: - writer.WriteStringValue("int"); - return; + writer.WriteStringValue(MemberInteger); + break; case DelimitedPayloadEncoding.Identity: - writer.WriteStringValue("identity"); - return; + writer.WriteStringValue(MemberIdentity); + break; case DelimitedPayloadEncoding.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DelimitedPayloadEncoding)}'."); } - - writer.WriteNullValue(); } } @@ -86,36 +95,40 @@ public enum EdgeNGramSide Back } -internal sealed class EdgeNGramSideConverter : JsonConverter +internal sealed partial class EdgeNGramSideConverter : System.Text.Json.Serialization.JsonConverter { - public override EdgeNGramSide Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFront = System.Text.Json.JsonEncodedText.Encode("front"); + private static readonly System.Text.Json.JsonEncodedText MemberBack = System.Text.Json.JsonEncodedText.Encode("back"); + + public override EdgeNGramSide Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFront)) + { + return EdgeNGramSide.Front; + } + + if (reader.ValueTextEquals(MemberBack)) { - case "front": - return EdgeNGramSide.Front; - case "back": - return EdgeNGramSide.Back; + return EdgeNGramSide.Back; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EdgeNGramSide)}'."); } - public override void Write(Utf8JsonWriter writer, EdgeNGramSide value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EdgeNGramSide value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EdgeNGramSide.Front: - writer.WriteStringValue("front"); - return; + writer.WriteStringValue(MemberFront); + break; case EdgeNGramSide.Back: - writer.WriteStringValue("back"); - return; + writer.WriteStringValue(MemberBack); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EdgeNGramSide)}'."); } - - writer.WriteNullValue(); } } @@ -128,36 +141,40 @@ public enum IcuCollationAlternate NonIgnorable } -internal sealed class IcuCollationAlternateConverter : JsonConverter +internal sealed partial class IcuCollationAlternateConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationAlternate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShifted = System.Text.Json.JsonEncodedText.Encode("shifted"); + private static readonly System.Text.Json.JsonEncodedText MemberNonIgnorable = System.Text.Json.JsonEncodedText.Encode("non-ignorable"); + + public override IcuCollationAlternate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShifted)) + { + return IcuCollationAlternate.Shifted; + } + + if (reader.ValueTextEquals(MemberNonIgnorable)) { - case "shifted": - return IcuCollationAlternate.Shifted; - case "non-ignorable": - return IcuCollationAlternate.NonIgnorable; + return IcuCollationAlternate.NonIgnorable; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationAlternate)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationAlternate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationAlternate value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationAlternate.Shifted: - writer.WriteStringValue("shifted"); - return; + writer.WriteStringValue(MemberShifted); + break; case IcuCollationAlternate.NonIgnorable: - writer.WriteStringValue("non-ignorable"); - return; + writer.WriteStringValue(MemberNonIgnorable); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationAlternate)}'."); } - - writer.WriteNullValue(); } } @@ -170,36 +187,40 @@ public enum IcuCollationCaseFirst Lower } -internal sealed class IcuCollationCaseFirstConverter : JsonConverter +internal sealed partial class IcuCollationCaseFirstConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationCaseFirst Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUpper = System.Text.Json.JsonEncodedText.Encode("upper"); + private static readonly System.Text.Json.JsonEncodedText MemberLower = System.Text.Json.JsonEncodedText.Encode("lower"); + + public override IcuCollationCaseFirst Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUpper)) { - case "upper": - return IcuCollationCaseFirst.Upper; - case "lower": - return IcuCollationCaseFirst.Lower; + return IcuCollationCaseFirst.Upper; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLower)) + { + return IcuCollationCaseFirst.Lower; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationCaseFirst)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationCaseFirst value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationCaseFirst value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationCaseFirst.Upper: - writer.WriteStringValue("upper"); - return; + writer.WriteStringValue(MemberUpper); + break; case IcuCollationCaseFirst.Lower: - writer.WriteStringValue("lower"); - return; + writer.WriteStringValue(MemberLower); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationCaseFirst)}'."); } - - writer.WriteNullValue(); } } @@ -212,36 +233,40 @@ public enum IcuCollationDecomposition Identical } -internal sealed class IcuCollationDecompositionConverter : JsonConverter +internal sealed partial class IcuCollationDecompositionConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationDecomposition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentical = System.Text.Json.JsonEncodedText.Encode("identical"); + + public override IcuCollationDecomposition Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNo)) + { + return IcuCollationDecomposition.No; + } + + if (reader.ValueTextEquals(MemberIdentical)) { - case "no": - return IcuCollationDecomposition.No; - case "identical": - return IcuCollationDecomposition.Identical; + return IcuCollationDecomposition.Identical; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationDecomposition)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationDecomposition value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationDecomposition value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationDecomposition.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case IcuCollationDecomposition.Identical: - writer.WriteStringValue("identical"); - return; + writer.WriteStringValue(MemberIdentical); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationDecomposition)}'."); } - - writer.WriteNullValue(); } } @@ -260,51 +285,67 @@ public enum IcuCollationStrength Identical } -internal sealed class IcuCollationStrengthConverter : JsonConverter +internal sealed partial class IcuCollationStrengthConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationStrength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTertiary = System.Text.Json.JsonEncodedText.Encode("tertiary"); + private static readonly System.Text.Json.JsonEncodedText MemberSecondary = System.Text.Json.JsonEncodedText.Encode("secondary"); + private static readonly System.Text.Json.JsonEncodedText MemberQuaternary = System.Text.Json.JsonEncodedText.Encode("quaternary"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentical = System.Text.Json.JsonEncodedText.Encode("identical"); + + public override IcuCollationStrength Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "tertiary": - return IcuCollationStrength.Tertiary; - case "secondary": - return IcuCollationStrength.Secondary; - case "quaternary": - return IcuCollationStrength.Quaternary; - case "primary": - return IcuCollationStrength.Primary; - case "identical": - return IcuCollationStrength.Identical; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTertiary)) + { + return IcuCollationStrength.Tertiary; + } + + if (reader.ValueTextEquals(MemberSecondary)) + { + return IcuCollationStrength.Secondary; + } + + if (reader.ValueTextEquals(MemberQuaternary)) + { + return IcuCollationStrength.Quaternary; + } + + if (reader.ValueTextEquals(MemberPrimary)) + { + return IcuCollationStrength.Primary; + } + + if (reader.ValueTextEquals(MemberIdentical)) + { + return IcuCollationStrength.Identical; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationStrength)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationStrength value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationStrength value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationStrength.Tertiary: - writer.WriteStringValue("tertiary"); - return; + writer.WriteStringValue(MemberTertiary); + break; case IcuCollationStrength.Secondary: - writer.WriteStringValue("secondary"); - return; + writer.WriteStringValue(MemberSecondary); + break; case IcuCollationStrength.Quaternary: - writer.WriteStringValue("quaternary"); - return; + writer.WriteStringValue(MemberQuaternary); + break; case IcuCollationStrength.Primary: - writer.WriteStringValue("primary"); - return; + writer.WriteStringValue(MemberPrimary); + break; case IcuCollationStrength.Identical: - writer.WriteStringValue("identical"); - return; + writer.WriteStringValue(MemberIdentical); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationStrength)}'."); } - - writer.WriteNullValue(); } } @@ -317,36 +358,40 @@ public enum IcuNormalizationMode Compose } -internal sealed class IcuNormalizationModeConverter : JsonConverter +internal sealed partial class IcuNormalizationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuNormalizationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDecompose = System.Text.Json.JsonEncodedText.Encode("decompose"); + private static readonly System.Text.Json.JsonEncodedText MemberCompose = System.Text.Json.JsonEncodedText.Encode("compose"); + + public override IcuNormalizationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDecompose)) { - case "decompose": - return IcuNormalizationMode.Decompose; - case "compose": - return IcuNormalizationMode.Compose; + return IcuNormalizationMode.Decompose; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCompose)) + { + return IcuNormalizationMode.Compose; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuNormalizationMode)}'."); } - public override void Write(Utf8JsonWriter writer, IcuNormalizationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuNormalizationMode.Decompose: - writer.WriteStringValue("decompose"); - return; + writer.WriteStringValue(MemberDecompose); + break; case IcuNormalizationMode.Compose: - writer.WriteStringValue("compose"); - return; + writer.WriteStringValue(MemberCompose); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuNormalizationMode)}'."); } - - writer.WriteNullValue(); } } @@ -361,41 +406,49 @@ public enum IcuNormalizationType Nfc } -internal sealed class IcuNormalizationTypeConverter : JsonConverter +internal sealed partial class IcuNormalizationTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuNormalizationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNfkcCf = System.Text.Json.JsonEncodedText.Encode("nfkc_cf"); + private static readonly System.Text.Json.JsonEncodedText MemberNfkc = System.Text.Json.JsonEncodedText.Encode("nfkc"); + private static readonly System.Text.Json.JsonEncodedText MemberNfc = System.Text.Json.JsonEncodedText.Encode("nfc"); + + public override IcuNormalizationType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNfkcCf)) + { + return IcuNormalizationType.NfkcCf; + } + + if (reader.ValueTextEquals(MemberNfkc)) + { + return IcuNormalizationType.Nfkc; + } + + if (reader.ValueTextEquals(MemberNfc)) { - case "nfkc_cf": - return IcuNormalizationType.NfkcCf; - case "nfkc": - return IcuNormalizationType.Nfkc; - case "nfc": - return IcuNormalizationType.Nfc; + return IcuNormalizationType.Nfc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuNormalizationType)}'."); } - public override void Write(Utf8JsonWriter writer, IcuNormalizationType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuNormalizationType.NfkcCf: - writer.WriteStringValue("nfkc_cf"); - return; + writer.WriteStringValue(MemberNfkcCf); + break; case IcuNormalizationType.Nfkc: - writer.WriteStringValue("nfkc"); - return; + writer.WriteStringValue(MemberNfkc); + break; case IcuNormalizationType.Nfc: - writer.WriteStringValue("nfc"); - return; + writer.WriteStringValue(MemberNfc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuNormalizationType)}'."); } - - writer.WriteNullValue(); } } @@ -408,36 +461,40 @@ public enum IcuTransformDirection Forward } -internal sealed class IcuTransformDirectionConverter : JsonConverter +internal sealed partial class IcuTransformDirectionConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuTransformDirection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReverse = System.Text.Json.JsonEncodedText.Encode("reverse"); + private static readonly System.Text.Json.JsonEncodedText MemberForward = System.Text.Json.JsonEncodedText.Encode("forward"); + + public override IcuTransformDirection Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReverse)) + { + return IcuTransformDirection.Reverse; + } + + if (reader.ValueTextEquals(MemberForward)) { - case "reverse": - return IcuTransformDirection.Reverse; - case "forward": - return IcuTransformDirection.Forward; + return IcuTransformDirection.Forward; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuTransformDirection)}'."); } - public override void Write(Utf8JsonWriter writer, IcuTransformDirection value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuTransformDirection value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuTransformDirection.Reverse: - writer.WriteStringValue("reverse"); - return; + writer.WriteStringValue(MemberReverse); + break; case IcuTransformDirection.Forward: - writer.WriteStringValue("forward"); - return; + writer.WriteStringValue(MemberForward); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuTransformDirection)}'."); } - - writer.WriteNullValue(); } } @@ -450,36 +507,40 @@ public enum KeepTypesMode Exclude } -internal sealed class KeepTypesModeConverter : JsonConverter +internal sealed partial class KeepTypesModeConverter : System.Text.Json.Serialization.JsonConverter { - public override KeepTypesMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override KeepTypesMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInclude)) { - case "include": - return KeepTypesMode.Include; - case "exclude": - return KeepTypesMode.Exclude; + return KeepTypesMode.Include; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExclude)) + { + return KeepTypesMode.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(KeepTypesMode)}'."); } - public override void Write(Utf8JsonWriter writer, KeepTypesMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeepTypesMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case KeepTypesMode.Include: - writer.WriteStringValue("include"); - return; + writer.WriteStringValue(MemberInclude); + break; case KeepTypesMode.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(KeepTypesMode)}'."); } - - writer.WriteNullValue(); } } @@ -494,41 +555,49 @@ public enum KuromojiTokenizationMode Extended } -internal sealed class KuromojiTokenizationModeConverter : JsonConverter +internal sealed partial class KuromojiTokenizationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override KuromojiTokenizationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberExtended = System.Text.Json.JsonEncodedText.Encode("extended"); + + public override KuromojiTokenizationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSearch)) { - case "search": - return KuromojiTokenizationMode.Search; - case "normal": - return KuromojiTokenizationMode.Normal; - case "extended": - return KuromojiTokenizationMode.Extended; + return KuromojiTokenizationMode.Search; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNormal)) + { + return KuromojiTokenizationMode.Normal; + } + + if (reader.ValueTextEquals(MemberExtended)) + { + return KuromojiTokenizationMode.Extended; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(KuromojiTokenizationMode)}'."); } - public override void Write(Utf8JsonWriter writer, KuromojiTokenizationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, KuromojiTokenizationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case KuromojiTokenizationMode.Search: - writer.WriteStringValue("search"); - return; + writer.WriteStringValue(MemberSearch); + break; case KuromojiTokenizationMode.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case KuromojiTokenizationMode.Extended: - writer.WriteStringValue("extended"); - return; + writer.WriteStringValue(MemberExtended); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(KuromojiTokenizationMode)}'."); } - - writer.WriteNullValue(); } } @@ -605,196 +674,328 @@ public enum Language Arabic } -internal sealed class LanguageConverter : JsonConverter +internal sealed partial class LanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override Language Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTurkish = System.Text.Json.JsonEncodedText.Encode("Turkish"); + private static readonly System.Text.Json.JsonEncodedText MemberThai = System.Text.Json.JsonEncodedText.Encode("Thai"); + private static readonly System.Text.Json.JsonEncodedText MemberSwedish = System.Text.Json.JsonEncodedText.Encode("Swedish"); + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("Spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberSorani = System.Text.Json.JsonEncodedText.Encode("Sorani"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("Russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("Romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPortuguese = System.Text.Json.JsonEncodedText.Encode("Portuguese"); + private static readonly System.Text.Json.JsonEncodedText MemberPersian = System.Text.Json.JsonEncodedText.Encode("Persian"); + private static readonly System.Text.Json.JsonEncodedText MemberNorwegian = System.Text.Json.JsonEncodedText.Encode("Norwegian"); + private static readonly System.Text.Json.JsonEncodedText MemberLatvian = System.Text.Json.JsonEncodedText.Encode("Latvian"); + private static readonly System.Text.Json.JsonEncodedText MemberItalian = System.Text.Json.JsonEncodedText.Encode("Italian"); + private static readonly System.Text.Json.JsonEncodedText MemberIrish = System.Text.Json.JsonEncodedText.Encode("Irish"); + private static readonly System.Text.Json.JsonEncodedText MemberIndonesian = System.Text.Json.JsonEncodedText.Encode("Indonesian"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("Hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberHindi = System.Text.Json.JsonEncodedText.Encode("Hindi"); + private static readonly System.Text.Json.JsonEncodedText MemberGreek = System.Text.Json.JsonEncodedText.Encode("Greek"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("German"); + private static readonly System.Text.Json.JsonEncodedText MemberGalician = System.Text.Json.JsonEncodedText.Encode("Galician"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("French"); + private static readonly System.Text.Json.JsonEncodedText MemberFinnish = System.Text.Json.JsonEncodedText.Encode("Finnish"); + private static readonly System.Text.Json.JsonEncodedText MemberEstonian = System.Text.Json.JsonEncodedText.Encode("Estonian"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("English"); + private static readonly System.Text.Json.JsonEncodedText MemberDutch = System.Text.Json.JsonEncodedText.Encode("Dutch"); + private static readonly System.Text.Json.JsonEncodedText MemberDanish = System.Text.Json.JsonEncodedText.Encode("Danish"); + private static readonly System.Text.Json.JsonEncodedText MemberCzech = System.Text.Json.JsonEncodedText.Encode("Czech"); + private static readonly System.Text.Json.JsonEncodedText MemberCjk = System.Text.Json.JsonEncodedText.Encode("Cjk"); + private static readonly System.Text.Json.JsonEncodedText MemberChinese = System.Text.Json.JsonEncodedText.Encode("Chinese"); + private static readonly System.Text.Json.JsonEncodedText MemberCatalan = System.Text.Json.JsonEncodedText.Encode("Catalan"); + private static readonly System.Text.Json.JsonEncodedText MemberBulgarian = System.Text.Json.JsonEncodedText.Encode("Bulgarian"); + private static readonly System.Text.Json.JsonEncodedText MemberBrazilian = System.Text.Json.JsonEncodedText.Encode("Brazilian"); + private static readonly System.Text.Json.JsonEncodedText MemberBasque = System.Text.Json.JsonEncodedText.Encode("Basque"); + private static readonly System.Text.Json.JsonEncodedText MemberArmenian = System.Text.Json.JsonEncodedText.Encode("Armenian"); + private static readonly System.Text.Json.JsonEncodedText MemberArabic = System.Text.Json.JsonEncodedText.Encode("Arabic"); + + public override Language Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "Turkish": - return Language.Turkish; - case "Thai": - return Language.Thai; - case "Swedish": - return Language.Swedish; - case "Spanish": - return Language.Spanish; - case "Sorani": - return Language.Sorani; - case "Russian": - return Language.Russian; - case "Romanian": - return Language.Romanian; - case "Portuguese": - return Language.Portuguese; - case "Persian": - return Language.Persian; - case "Norwegian": - return Language.Norwegian; - case "Latvian": - return Language.Latvian; - case "Italian": - return Language.Italian; - case "Irish": - return Language.Irish; - case "Indonesian": - return Language.Indonesian; - case "Hungarian": - return Language.Hungarian; - case "Hindi": - return Language.Hindi; - case "Greek": - return Language.Greek; - case "German": - return Language.German; - case "Galician": - return Language.Galician; - case "French": - return Language.French; - case "Finnish": - return Language.Finnish; - case "Estonian": - return Language.Estonian; - case "English": - return Language.English; - case "Dutch": - return Language.Dutch; - case "Danish": - return Language.Danish; - case "Czech": - return Language.Czech; - case "Cjk": - return Language.Cjk; - case "Chinese": - return Language.Chinese; - case "Catalan": - return Language.Catalan; - case "Bulgarian": - return Language.Bulgarian; - case "Brazilian": - return Language.Brazilian; - case "Basque": - return Language.Basque; - case "Armenian": - return Language.Armenian; - case "Arabic": - return Language.Arabic; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTurkish)) + { + return Language.Turkish; + } + + if (reader.ValueTextEquals(MemberThai)) + { + return Language.Thai; + } + + if (reader.ValueTextEquals(MemberSwedish)) + { + return Language.Swedish; + } + + if (reader.ValueTextEquals(MemberSpanish)) + { + return Language.Spanish; + } + + if (reader.ValueTextEquals(MemberSorani)) + { + return Language.Sorani; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return Language.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return Language.Romanian; + } + + if (reader.ValueTextEquals(MemberPortuguese)) + { + return Language.Portuguese; + } + + if (reader.ValueTextEquals(MemberPersian)) + { + return Language.Persian; + } + + if (reader.ValueTextEquals(MemberNorwegian)) + { + return Language.Norwegian; + } + + if (reader.ValueTextEquals(MemberLatvian)) + { + return Language.Latvian; + } + + if (reader.ValueTextEquals(MemberItalian)) + { + return Language.Italian; + } + + if (reader.ValueTextEquals(MemberIrish)) + { + return Language.Irish; + } + + if (reader.ValueTextEquals(MemberIndonesian)) + { + return Language.Indonesian; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return Language.Hungarian; + } + + if (reader.ValueTextEquals(MemberHindi)) + { + return Language.Hindi; + } + + if (reader.ValueTextEquals(MemberGreek)) + { + return Language.Greek; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return Language.German; + } + + if (reader.ValueTextEquals(MemberGalician)) + { + return Language.Galician; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return Language.French; + } + + if (reader.ValueTextEquals(MemberFinnish)) + { + return Language.Finnish; + } + + if (reader.ValueTextEquals(MemberEstonian)) + { + return Language.Estonian; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return Language.English; + } + + if (reader.ValueTextEquals(MemberDutch)) + { + return Language.Dutch; + } + + if (reader.ValueTextEquals(MemberDanish)) + { + return Language.Danish; + } + + if (reader.ValueTextEquals(MemberCzech)) + { + return Language.Czech; + } + + if (reader.ValueTextEquals(MemberCjk)) + { + return Language.Cjk; + } + + if (reader.ValueTextEquals(MemberChinese)) + { + return Language.Chinese; + } + + if (reader.ValueTextEquals(MemberCatalan)) + { + return Language.Catalan; + } + + if (reader.ValueTextEquals(MemberBulgarian)) + { + return Language.Bulgarian; + } + + if (reader.ValueTextEquals(MemberBrazilian)) + { + return Language.Brazilian; + } + + if (reader.ValueTextEquals(MemberBasque)) + { + return Language.Basque; + } + + if (reader.ValueTextEquals(MemberArmenian)) + { + return Language.Armenian; + } + + if (reader.ValueTextEquals(MemberArabic)) + { + return Language.Arabic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Language)}'."); } - public override void Write(Utf8JsonWriter writer, Language value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Language value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Language.Turkish: - writer.WriteStringValue("Turkish"); - return; + writer.WriteStringValue(MemberTurkish); + break; case Language.Thai: - writer.WriteStringValue("Thai"); - return; + writer.WriteStringValue(MemberThai); + break; case Language.Swedish: - writer.WriteStringValue("Swedish"); - return; + writer.WriteStringValue(MemberSwedish); + break; case Language.Spanish: - writer.WriteStringValue("Spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case Language.Sorani: - writer.WriteStringValue("Sorani"); - return; + writer.WriteStringValue(MemberSorani); + break; case Language.Russian: - writer.WriteStringValue("Russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case Language.Romanian: - writer.WriteStringValue("Romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case Language.Portuguese: - writer.WriteStringValue("Portuguese"); - return; + writer.WriteStringValue(MemberPortuguese); + break; case Language.Persian: - writer.WriteStringValue("Persian"); - return; + writer.WriteStringValue(MemberPersian); + break; case Language.Norwegian: - writer.WriteStringValue("Norwegian"); - return; + writer.WriteStringValue(MemberNorwegian); + break; case Language.Latvian: - writer.WriteStringValue("Latvian"); - return; + writer.WriteStringValue(MemberLatvian); + break; case Language.Italian: - writer.WriteStringValue("Italian"); - return; + writer.WriteStringValue(MemberItalian); + break; case Language.Irish: - writer.WriteStringValue("Irish"); - return; + writer.WriteStringValue(MemberIrish); + break; case Language.Indonesian: - writer.WriteStringValue("Indonesian"); - return; + writer.WriteStringValue(MemberIndonesian); + break; case Language.Hungarian: - writer.WriteStringValue("Hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case Language.Hindi: - writer.WriteStringValue("Hindi"); - return; + writer.WriteStringValue(MemberHindi); + break; case Language.Greek: - writer.WriteStringValue("Greek"); - return; + writer.WriteStringValue(MemberGreek); + break; case Language.German: - writer.WriteStringValue("German"); - return; + writer.WriteStringValue(MemberGerman); + break; case Language.Galician: - writer.WriteStringValue("Galician"); - return; + writer.WriteStringValue(MemberGalician); + break; case Language.French: - writer.WriteStringValue("French"); - return; + writer.WriteStringValue(MemberFrench); + break; case Language.Finnish: - writer.WriteStringValue("Finnish"); - return; + writer.WriteStringValue(MemberFinnish); + break; case Language.Estonian: - writer.WriteStringValue("Estonian"); - return; + writer.WriteStringValue(MemberEstonian); + break; case Language.English: - writer.WriteStringValue("English"); - return; + writer.WriteStringValue(MemberEnglish); + break; case Language.Dutch: - writer.WriteStringValue("Dutch"); - return; + writer.WriteStringValue(MemberDutch); + break; case Language.Danish: - writer.WriteStringValue("Danish"); - return; + writer.WriteStringValue(MemberDanish); + break; case Language.Czech: - writer.WriteStringValue("Czech"); - return; + writer.WriteStringValue(MemberCzech); + break; case Language.Cjk: - writer.WriteStringValue("Cjk"); - return; + writer.WriteStringValue(MemberCjk); + break; case Language.Chinese: - writer.WriteStringValue("Chinese"); - return; + writer.WriteStringValue(MemberChinese); + break; case Language.Catalan: - writer.WriteStringValue("Catalan"); - return; + writer.WriteStringValue(MemberCatalan); + break; case Language.Bulgarian: - writer.WriteStringValue("Bulgarian"); - return; + writer.WriteStringValue(MemberBulgarian); + break; case Language.Brazilian: - writer.WriteStringValue("Brazilian"); - return; + writer.WriteStringValue(MemberBrazilian); + break; case Language.Basque: - writer.WriteStringValue("Basque"); - return; + writer.WriteStringValue(MemberBasque); + break; case Language.Armenian: - writer.WriteStringValue("Armenian"); - return; + writer.WriteStringValue(MemberArmenian); + break; case Language.Arabic: - writer.WriteStringValue("Arabic"); - return; + writer.WriteStringValue(MemberArabic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Language)}'."); } - - writer.WriteNullValue(); } } @@ -809,41 +1010,49 @@ public enum NoriDecompoundMode Discard } -internal sealed class NoriDecompoundModeConverter : JsonConverter +internal sealed partial class NoriDecompoundModeConverter : System.Text.Json.Serialization.JsonConverter { - public override NoriDecompoundMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberMixed = System.Text.Json.JsonEncodedText.Encode("mixed"); + private static readonly System.Text.Json.JsonEncodedText MemberDiscard = System.Text.Json.JsonEncodedText.Encode("discard"); + + public override NoriDecompoundMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) + { + return NoriDecompoundMode.None; + } + + if (reader.ValueTextEquals(MemberMixed)) { - case "none": - return NoriDecompoundMode.None; - case "mixed": - return NoriDecompoundMode.Mixed; - case "discard": - return NoriDecompoundMode.Discard; + return NoriDecompoundMode.Mixed; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDiscard)) + { + return NoriDecompoundMode.Discard; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NoriDecompoundMode)}'."); } - public override void Write(Utf8JsonWriter writer, NoriDecompoundMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NoriDecompoundMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NoriDecompoundMode.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case NoriDecompoundMode.Mixed: - writer.WriteStringValue("mixed"); - return; + writer.WriteStringValue(MemberMixed); + break; case NoriDecompoundMode.Discard: - writer.WriteStringValue("discard"); - return; + writer.WriteStringValue(MemberDiscard); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NoriDecompoundMode)}'."); } - - writer.WriteNullValue(); } } @@ -876,86 +1085,130 @@ public enum PhoneticEncoder BeiderMorse } -internal sealed class PhoneticEncoderConverter : JsonConverter +internal sealed partial class PhoneticEncoderConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticEncoder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSoundex = System.Text.Json.JsonEncodedText.Encode("soundex"); + private static readonly System.Text.Json.JsonEncodedText MemberRefinedSoundex = System.Text.Json.JsonEncodedText.Encode("refined_soundex"); + private static readonly System.Text.Json.JsonEncodedText MemberNysiis = System.Text.Json.JsonEncodedText.Encode("nysiis"); + private static readonly System.Text.Json.JsonEncodedText MemberMetaphone = System.Text.Json.JsonEncodedText.Encode("metaphone"); + private static readonly System.Text.Json.JsonEncodedText MemberKoelnerphonetik = System.Text.Json.JsonEncodedText.Encode("koelnerphonetik"); + private static readonly System.Text.Json.JsonEncodedText MemberHaasephonetik = System.Text.Json.JsonEncodedText.Encode("haasephonetik"); + private static readonly System.Text.Json.JsonEncodedText MemberDoubleMetaphone = System.Text.Json.JsonEncodedText.Encode("double_metaphone"); + private static readonly System.Text.Json.JsonEncodedText MemberDaitchMokotoff = System.Text.Json.JsonEncodedText.Encode("daitch_mokotoff"); + private static readonly System.Text.Json.JsonEncodedText MemberCologne = System.Text.Json.JsonEncodedText.Encode("cologne"); + private static readonly System.Text.Json.JsonEncodedText MemberCaverphone2 = System.Text.Json.JsonEncodedText.Encode("caverphone2"); + private static readonly System.Text.Json.JsonEncodedText MemberCaverphone1 = System.Text.Json.JsonEncodedText.Encode("caverphone1"); + private static readonly System.Text.Json.JsonEncodedText MemberBeiderMorse = System.Text.Json.JsonEncodedText.Encode("beider_morse"); + + public override PhoneticEncoder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "soundex": - return PhoneticEncoder.Soundex; - case "refined_soundex": - return PhoneticEncoder.RefinedSoundex; - case "nysiis": - return PhoneticEncoder.Nysiis; - case "metaphone": - return PhoneticEncoder.Metaphone; - case "koelnerphonetik": - return PhoneticEncoder.Koelnerphonetik; - case "haasephonetik": - return PhoneticEncoder.Haasephonetik; - case "double_metaphone": - return PhoneticEncoder.DoubleMetaphone; - case "daitch_mokotoff": - return PhoneticEncoder.DaitchMokotoff; - case "cologne": - return PhoneticEncoder.Cologne; - case "caverphone2": - return PhoneticEncoder.Caverphone2; - case "caverphone1": - return PhoneticEncoder.Caverphone1; - case "beider_morse": - return PhoneticEncoder.BeiderMorse; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSoundex)) + { + return PhoneticEncoder.Soundex; + } + + if (reader.ValueTextEquals(MemberRefinedSoundex)) + { + return PhoneticEncoder.RefinedSoundex; + } + + if (reader.ValueTextEquals(MemberNysiis)) + { + return PhoneticEncoder.Nysiis; + } + + if (reader.ValueTextEquals(MemberMetaphone)) + { + return PhoneticEncoder.Metaphone; + } + + if (reader.ValueTextEquals(MemberKoelnerphonetik)) + { + return PhoneticEncoder.Koelnerphonetik; + } + + if (reader.ValueTextEquals(MemberHaasephonetik)) + { + return PhoneticEncoder.Haasephonetik; + } + + if (reader.ValueTextEquals(MemberDoubleMetaphone)) + { + return PhoneticEncoder.DoubleMetaphone; + } + + if (reader.ValueTextEquals(MemberDaitchMokotoff)) + { + return PhoneticEncoder.DaitchMokotoff; + } + + if (reader.ValueTextEquals(MemberCologne)) + { + return PhoneticEncoder.Cologne; + } + + if (reader.ValueTextEquals(MemberCaverphone2)) + { + return PhoneticEncoder.Caverphone2; + } + + if (reader.ValueTextEquals(MemberCaverphone1)) + { + return PhoneticEncoder.Caverphone1; + } + + if (reader.ValueTextEquals(MemberBeiderMorse)) + { + return PhoneticEncoder.BeiderMorse; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticEncoder)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticEncoder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticEncoder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticEncoder.Soundex: - writer.WriteStringValue("soundex"); - return; + writer.WriteStringValue(MemberSoundex); + break; case PhoneticEncoder.RefinedSoundex: - writer.WriteStringValue("refined_soundex"); - return; + writer.WriteStringValue(MemberRefinedSoundex); + break; case PhoneticEncoder.Nysiis: - writer.WriteStringValue("nysiis"); - return; + writer.WriteStringValue(MemberNysiis); + break; case PhoneticEncoder.Metaphone: - writer.WriteStringValue("metaphone"); - return; + writer.WriteStringValue(MemberMetaphone); + break; case PhoneticEncoder.Koelnerphonetik: - writer.WriteStringValue("koelnerphonetik"); - return; + writer.WriteStringValue(MemberKoelnerphonetik); + break; case PhoneticEncoder.Haasephonetik: - writer.WriteStringValue("haasephonetik"); - return; + writer.WriteStringValue(MemberHaasephonetik); + break; case PhoneticEncoder.DoubleMetaphone: - writer.WriteStringValue("double_metaphone"); - return; + writer.WriteStringValue(MemberDoubleMetaphone); + break; case PhoneticEncoder.DaitchMokotoff: - writer.WriteStringValue("daitch_mokotoff"); - return; + writer.WriteStringValue(MemberDaitchMokotoff); + break; case PhoneticEncoder.Cologne: - writer.WriteStringValue("cologne"); - return; + writer.WriteStringValue(MemberCologne); + break; case PhoneticEncoder.Caverphone2: - writer.WriteStringValue("caverphone2"); - return; + writer.WriteStringValue(MemberCaverphone2); + break; case PhoneticEncoder.Caverphone1: - writer.WriteStringValue("caverphone1"); - return; + writer.WriteStringValue(MemberCaverphone1); + break; case PhoneticEncoder.BeiderMorse: - writer.WriteStringValue("beider_morse"); - return; + writer.WriteStringValue(MemberBeiderMorse); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticEncoder)}'."); } - - writer.WriteNullValue(); } } @@ -988,86 +1241,130 @@ public enum PhoneticLanguage Any } -internal sealed class PhoneticLanguageConverter : JsonConverter +internal sealed partial class PhoneticLanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPolish = System.Text.Json.JsonEncodedText.Encode("polish"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberHebrew = System.Text.Json.JsonEncodedText.Encode("hebrew"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("german"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("french"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("english"); + private static readonly System.Text.Json.JsonEncodedText MemberCyrillic = System.Text.Json.JsonEncodedText.Encode("cyrillic"); + private static readonly System.Text.Json.JsonEncodedText MemberCommon = System.Text.Json.JsonEncodedText.Encode("common"); + private static readonly System.Text.Json.JsonEncodedText MemberAny = System.Text.Json.JsonEncodedText.Encode("any"); + + public override PhoneticLanguage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "spanish": - return PhoneticLanguage.Spanish; - case "russian": - return PhoneticLanguage.Russian; - case "romanian": - return PhoneticLanguage.Romanian; - case "polish": - return PhoneticLanguage.Polish; - case "hungarian": - return PhoneticLanguage.Hungarian; - case "hebrew": - return PhoneticLanguage.Hebrew; - case "german": - return PhoneticLanguage.German; - case "french": - return PhoneticLanguage.French; - case "english": - return PhoneticLanguage.English; - case "cyrillic": - return PhoneticLanguage.Cyrillic; - case "common": - return PhoneticLanguage.Common; - case "any": - return PhoneticLanguage.Any; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpanish)) + { + return PhoneticLanguage.Spanish; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return PhoneticLanguage.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return PhoneticLanguage.Romanian; + } + + if (reader.ValueTextEquals(MemberPolish)) + { + return PhoneticLanguage.Polish; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return PhoneticLanguage.Hungarian; + } + + if (reader.ValueTextEquals(MemberHebrew)) + { + return PhoneticLanguage.Hebrew; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return PhoneticLanguage.German; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return PhoneticLanguage.French; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return PhoneticLanguage.English; + } + + if (reader.ValueTextEquals(MemberCyrillic)) + { + return PhoneticLanguage.Cyrillic; + } + + if (reader.ValueTextEquals(MemberCommon)) + { + return PhoneticLanguage.Common; + } + + if (reader.ValueTextEquals(MemberAny)) + { + return PhoneticLanguage.Any; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticLanguage)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticLanguage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticLanguage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticLanguage.Spanish: - writer.WriteStringValue("spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case PhoneticLanguage.Russian: - writer.WriteStringValue("russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case PhoneticLanguage.Romanian: - writer.WriteStringValue("romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case PhoneticLanguage.Polish: - writer.WriteStringValue("polish"); - return; + writer.WriteStringValue(MemberPolish); + break; case PhoneticLanguage.Hungarian: - writer.WriteStringValue("hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case PhoneticLanguage.Hebrew: - writer.WriteStringValue("hebrew"); - return; + writer.WriteStringValue(MemberHebrew); + break; case PhoneticLanguage.German: - writer.WriteStringValue("german"); - return; + writer.WriteStringValue(MemberGerman); + break; case PhoneticLanguage.French: - writer.WriteStringValue("french"); - return; + writer.WriteStringValue(MemberFrench); + break; case PhoneticLanguage.English: - writer.WriteStringValue("english"); - return; + writer.WriteStringValue(MemberEnglish); + break; case PhoneticLanguage.Cyrillic: - writer.WriteStringValue("cyrillic"); - return; + writer.WriteStringValue(MemberCyrillic); + break; case PhoneticLanguage.Common: - writer.WriteStringValue("common"); - return; + writer.WriteStringValue(MemberCommon); + break; case PhoneticLanguage.Any: - writer.WriteStringValue("any"); - return; + writer.WriteStringValue(MemberAny); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticLanguage)}'."); } - - writer.WriteNullValue(); } } @@ -1082,41 +1379,49 @@ public enum PhoneticNameType Ashkenazi } -internal sealed class PhoneticNameTypeConverter : JsonConverter +internal sealed partial class PhoneticNameTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticNameType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSephardic = System.Text.Json.JsonEncodedText.Encode("sephardic"); + private static readonly System.Text.Json.JsonEncodedText MemberGeneric = System.Text.Json.JsonEncodedText.Encode("generic"); + private static readonly System.Text.Json.JsonEncodedText MemberAshkenazi = System.Text.Json.JsonEncodedText.Encode("ashkenazi"); + + public override PhoneticNameType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSephardic)) + { + return PhoneticNameType.Sephardic; + } + + if (reader.ValueTextEquals(MemberGeneric)) + { + return PhoneticNameType.Generic; + } + + if (reader.ValueTextEquals(MemberAshkenazi)) { - case "sephardic": - return PhoneticNameType.Sephardic; - case "generic": - return PhoneticNameType.Generic; - case "ashkenazi": - return PhoneticNameType.Ashkenazi; + return PhoneticNameType.Ashkenazi; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticNameType)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticNameType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticNameType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticNameType.Sephardic: - writer.WriteStringValue("sephardic"); - return; + writer.WriteStringValue(MemberSephardic); + break; case PhoneticNameType.Generic: - writer.WriteStringValue("generic"); - return; + writer.WriteStringValue(MemberGeneric); + break; case PhoneticNameType.Ashkenazi: - writer.WriteStringValue("ashkenazi"); - return; + writer.WriteStringValue(MemberAshkenazi); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticNameType)}'."); } - - writer.WriteNullValue(); } } @@ -1129,36 +1434,40 @@ public enum PhoneticRuleType Approx } -internal sealed class PhoneticRuleTypeConverter : JsonConverter +internal sealed partial class PhoneticRuleTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticRuleType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberExact = System.Text.Json.JsonEncodedText.Encode("exact"); + private static readonly System.Text.Json.JsonEncodedText MemberApprox = System.Text.Json.JsonEncodedText.Encode("approx"); + + public override PhoneticRuleType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberExact)) { - case "exact": - return PhoneticRuleType.Exact; - case "approx": - return PhoneticRuleType.Approx; + return PhoneticRuleType.Exact; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberApprox)) + { + return PhoneticRuleType.Approx; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticRuleType)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticRuleType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticRuleType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticRuleType.Exact: - writer.WriteStringValue("exact"); - return; + writer.WriteStringValue(MemberExact); + break; case PhoneticRuleType.Approx: - writer.WriteStringValue("approx"); - return; + writer.WriteStringValue(MemberApprox); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticRuleType)}'."); } - - writer.WriteNullValue(); } } @@ -1211,136 +1520,220 @@ public enum SnowballLanguage Armenian } -internal sealed class SnowballLanguageConverter : JsonConverter +internal sealed partial class SnowballLanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override SnowballLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTurkish = System.Text.Json.JsonEncodedText.Encode("Turkish"); + private static readonly System.Text.Json.JsonEncodedText MemberSwedish = System.Text.Json.JsonEncodedText.Encode("Swedish"); + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("Spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("Russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("Romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPortuguese = System.Text.Json.JsonEncodedText.Encode("Portuguese"); + private static readonly System.Text.Json.JsonEncodedText MemberPorter = System.Text.Json.JsonEncodedText.Encode("Porter"); + private static readonly System.Text.Json.JsonEncodedText MemberNorwegian = System.Text.Json.JsonEncodedText.Encode("Norwegian"); + private static readonly System.Text.Json.JsonEncodedText MemberLovins = System.Text.Json.JsonEncodedText.Encode("Lovins"); + private static readonly System.Text.Json.JsonEncodedText MemberKp = System.Text.Json.JsonEncodedText.Encode("Kp"); + private static readonly System.Text.Json.JsonEncodedText MemberItalian = System.Text.Json.JsonEncodedText.Encode("Italian"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("Hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman2 = System.Text.Json.JsonEncodedText.Encode("German2"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("German"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("French"); + private static readonly System.Text.Json.JsonEncodedText MemberFinnish = System.Text.Json.JsonEncodedText.Encode("Finnish"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("English"); + private static readonly System.Text.Json.JsonEncodedText MemberDutch = System.Text.Json.JsonEncodedText.Encode("Dutch"); + private static readonly System.Text.Json.JsonEncodedText MemberDanish = System.Text.Json.JsonEncodedText.Encode("Danish"); + private static readonly System.Text.Json.JsonEncodedText MemberCatalan = System.Text.Json.JsonEncodedText.Encode("Catalan"); + private static readonly System.Text.Json.JsonEncodedText MemberBasque = System.Text.Json.JsonEncodedText.Encode("Basque"); + private static readonly System.Text.Json.JsonEncodedText MemberArmenian = System.Text.Json.JsonEncodedText.Encode("Armenian"); + + public override SnowballLanguage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "Turkish": - return SnowballLanguage.Turkish; - case "Swedish": - return SnowballLanguage.Swedish; - case "Spanish": - return SnowballLanguage.Spanish; - case "Russian": - return SnowballLanguage.Russian; - case "Romanian": - return SnowballLanguage.Romanian; - case "Portuguese": - return SnowballLanguage.Portuguese; - case "Porter": - return SnowballLanguage.Porter; - case "Norwegian": - return SnowballLanguage.Norwegian; - case "Lovins": - return SnowballLanguage.Lovins; - case "Kp": - return SnowballLanguage.Kp; - case "Italian": - return SnowballLanguage.Italian; - case "Hungarian": - return SnowballLanguage.Hungarian; - case "German2": - return SnowballLanguage.German2; - case "German": - return SnowballLanguage.German; - case "French": - return SnowballLanguage.French; - case "Finnish": - return SnowballLanguage.Finnish; - case "English": - return SnowballLanguage.English; - case "Dutch": - return SnowballLanguage.Dutch; - case "Danish": - return SnowballLanguage.Danish; - case "Catalan": - return SnowballLanguage.Catalan; - case "Basque": - return SnowballLanguage.Basque; - case "Armenian": - return SnowballLanguage.Armenian; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTurkish)) + { + return SnowballLanguage.Turkish; + } + + if (reader.ValueTextEquals(MemberSwedish)) + { + return SnowballLanguage.Swedish; + } + + if (reader.ValueTextEquals(MemberSpanish)) + { + return SnowballLanguage.Spanish; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return SnowballLanguage.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return SnowballLanguage.Romanian; + } + + if (reader.ValueTextEquals(MemberPortuguese)) + { + return SnowballLanguage.Portuguese; + } + + if (reader.ValueTextEquals(MemberPorter)) + { + return SnowballLanguage.Porter; + } + + if (reader.ValueTextEquals(MemberNorwegian)) + { + return SnowballLanguage.Norwegian; + } + + if (reader.ValueTextEquals(MemberLovins)) + { + return SnowballLanguage.Lovins; + } + + if (reader.ValueTextEquals(MemberKp)) + { + return SnowballLanguage.Kp; + } + + if (reader.ValueTextEquals(MemberItalian)) + { + return SnowballLanguage.Italian; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return SnowballLanguage.Hungarian; + } + + if (reader.ValueTextEquals(MemberGerman2)) + { + return SnowballLanguage.German2; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return SnowballLanguage.German; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return SnowballLanguage.French; + } + + if (reader.ValueTextEquals(MemberFinnish)) + { + return SnowballLanguage.Finnish; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return SnowballLanguage.English; + } + + if (reader.ValueTextEquals(MemberDutch)) + { + return SnowballLanguage.Dutch; + } + + if (reader.ValueTextEquals(MemberDanish)) + { + return SnowballLanguage.Danish; + } + + if (reader.ValueTextEquals(MemberCatalan)) + { + return SnowballLanguage.Catalan; + } + + if (reader.ValueTextEquals(MemberBasque)) + { + return SnowballLanguage.Basque; + } + + if (reader.ValueTextEquals(MemberArmenian)) + { + return SnowballLanguage.Armenian; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnowballLanguage)}'."); } - public override void Write(Utf8JsonWriter writer, SnowballLanguage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnowballLanguage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnowballLanguage.Turkish: - writer.WriteStringValue("Turkish"); - return; + writer.WriteStringValue(MemberTurkish); + break; case SnowballLanguage.Swedish: - writer.WriteStringValue("Swedish"); - return; + writer.WriteStringValue(MemberSwedish); + break; case SnowballLanguage.Spanish: - writer.WriteStringValue("Spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case SnowballLanguage.Russian: - writer.WriteStringValue("Russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case SnowballLanguage.Romanian: - writer.WriteStringValue("Romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case SnowballLanguage.Portuguese: - writer.WriteStringValue("Portuguese"); - return; + writer.WriteStringValue(MemberPortuguese); + break; case SnowballLanguage.Porter: - writer.WriteStringValue("Porter"); - return; + writer.WriteStringValue(MemberPorter); + break; case SnowballLanguage.Norwegian: - writer.WriteStringValue("Norwegian"); - return; + writer.WriteStringValue(MemberNorwegian); + break; case SnowballLanguage.Lovins: - writer.WriteStringValue("Lovins"); - return; + writer.WriteStringValue(MemberLovins); + break; case SnowballLanguage.Kp: - writer.WriteStringValue("Kp"); - return; + writer.WriteStringValue(MemberKp); + break; case SnowballLanguage.Italian: - writer.WriteStringValue("Italian"); - return; + writer.WriteStringValue(MemberItalian); + break; case SnowballLanguage.Hungarian: - writer.WriteStringValue("Hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case SnowballLanguage.German2: - writer.WriteStringValue("German2"); - return; + writer.WriteStringValue(MemberGerman2); + break; case SnowballLanguage.German: - writer.WriteStringValue("German"); - return; + writer.WriteStringValue(MemberGerman); + break; case SnowballLanguage.French: - writer.WriteStringValue("French"); - return; + writer.WriteStringValue(MemberFrench); + break; case SnowballLanguage.Finnish: - writer.WriteStringValue("Finnish"); - return; + writer.WriteStringValue(MemberFinnish); + break; case SnowballLanguage.English: - writer.WriteStringValue("English"); - return; + writer.WriteStringValue(MemberEnglish); + break; case SnowballLanguage.Dutch: - writer.WriteStringValue("Dutch"); - return; + writer.WriteStringValue(MemberDutch); + break; case SnowballLanguage.Danish: - writer.WriteStringValue("Danish"); - return; + writer.WriteStringValue(MemberDanish); + break; case SnowballLanguage.Catalan: - writer.WriteStringValue("Catalan"); - return; + writer.WriteStringValue(MemberCatalan); + break; case SnowballLanguage.Basque: - writer.WriteStringValue("Basque"); - return; + writer.WriteStringValue(MemberBasque); + break; case SnowballLanguage.Armenian: - writer.WriteStringValue("Armenian"); - return; + writer.WriteStringValue(MemberArmenian); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnowballLanguage)}'."); } - - writer.WriteNullValue(); } } @@ -1353,36 +1746,40 @@ public enum SynonymFormat Solr } -internal sealed class SynonymFormatConverter : JsonConverter +internal sealed partial class SynonymFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override SynonymFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWordnet = System.Text.Json.JsonEncodedText.Encode("wordnet"); + private static readonly System.Text.Json.JsonEncodedText MemberSolr = System.Text.Json.JsonEncodedText.Encode("solr"); + + public override SynonymFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWordnet)) { - case "wordnet": - return SynonymFormat.Wordnet; - case "solr": - return SynonymFormat.Solr; + return SynonymFormat.Wordnet; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSolr)) + { + return SynonymFormat.Solr; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SynonymFormat)}'."); } - public override void Write(Utf8JsonWriter writer, SynonymFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SynonymFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SynonymFormat.Wordnet: - writer.WriteStringValue("wordnet"); - return; + writer.WriteStringValue(MemberWordnet); + break; case SynonymFormat.Solr: - writer.WriteStringValue("solr"); - return; + writer.WriteStringValue(MemberSolr); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SynonymFormat)}'."); } - - writer.WriteNullValue(); } } @@ -1403,55 +1800,75 @@ public enum TokenChar Custom } -internal sealed class TokenCharConverter : JsonConverter +internal sealed partial class TokenCharConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenChar Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWhitespace = System.Text.Json.JsonEncodedText.Encode("whitespace"); + private static readonly System.Text.Json.JsonEncodedText MemberSymbol = System.Text.Json.JsonEncodedText.Encode("symbol"); + private static readonly System.Text.Json.JsonEncodedText MemberPunctuation = System.Text.Json.JsonEncodedText.Encode("punctuation"); + private static readonly System.Text.Json.JsonEncodedText MemberLetter = System.Text.Json.JsonEncodedText.Encode("letter"); + private static readonly System.Text.Json.JsonEncodedText MemberDigit = System.Text.Json.JsonEncodedText.Encode("digit"); + private static readonly System.Text.Json.JsonEncodedText MemberCustom = System.Text.Json.JsonEncodedText.Encode("custom"); + + public override TokenChar Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "whitespace": - return TokenChar.Whitespace; - case "symbol": - return TokenChar.Symbol; - case "punctuation": - return TokenChar.Punctuation; - case "letter": - return TokenChar.Letter; - case "digit": - return TokenChar.Digit; - case "custom": - return TokenChar.Custom; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWhitespace)) + { + return TokenChar.Whitespace; + } + + if (reader.ValueTextEquals(MemberSymbol)) + { + return TokenChar.Symbol; + } + + if (reader.ValueTextEquals(MemberPunctuation)) + { + return TokenChar.Punctuation; + } + + if (reader.ValueTextEquals(MemberLetter)) + { + return TokenChar.Letter; + } + + if (reader.ValueTextEquals(MemberDigit)) + { + return TokenChar.Digit; + } + + if (reader.ValueTextEquals(MemberCustom)) + { + return TokenChar.Custom; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TokenChar)}'."); } - public override void Write(Utf8JsonWriter writer, TokenChar value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenChar value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TokenChar.Whitespace: - writer.WriteStringValue("whitespace"); - return; + writer.WriteStringValue(MemberWhitespace); + break; case TokenChar.Symbol: - writer.WriteStringValue("symbol"); - return; + writer.WriteStringValue(MemberSymbol); + break; case TokenChar.Punctuation: - writer.WriteStringValue("punctuation"); - return; + writer.WriteStringValue(MemberPunctuation); + break; case TokenChar.Letter: - writer.WriteStringValue("letter"); - return; + writer.WriteStringValue(MemberLetter); + break; case TokenChar.Digit: - writer.WriteStringValue("digit"); - return; + writer.WriteStringValue(MemberDigit); + break; case TokenChar.Custom: - writer.WriteStringValue("custom"); - return; + writer.WriteStringValue(MemberCustom); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TokenChar)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Cluster.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Cluster.g.cs index 3f580204a26..f9d9026cb40 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Cluster.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Cluster.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum AllocationExplainDecision Always } -internal sealed class AllocationExplainDecisionConverter : JsonConverter +internal sealed partial class AllocationExplainDecisionConverter : System.Text.Json.Serialization.JsonConverter { - public override AllocationExplainDecision Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("YES"); + private static readonly System.Text.Json.JsonEncodedText MemberThrottle = System.Text.Json.JsonEncodedText.Encode("THROTTLE"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("NO"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("ALWAYS"); + + public override AllocationExplainDecision Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return AllocationExplainDecision.Yes; + } + + if (reader.ValueTextEquals(MemberThrottle)) + { + return AllocationExplainDecision.Throttle; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return AllocationExplainDecision.No; + } + + if (reader.ValueTextEquals(MemberAlways)) { - case "YES": - return AllocationExplainDecision.Yes; - case "THROTTLE": - return AllocationExplainDecision.Throttle; - case "NO": - return AllocationExplainDecision.No; - case "ALWAYS": - return AllocationExplainDecision.Always; + return AllocationExplainDecision.Always; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AllocationExplainDecision)}'."); } - public override void Write(Utf8JsonWriter writer, AllocationExplainDecision value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AllocationExplainDecision value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AllocationExplainDecision.Yes: - writer.WriteStringValue("YES"); - return; + writer.WriteStringValue(MemberYes); + break; case AllocationExplainDecision.Throttle: - writer.WriteStringValue("THROTTLE"); - return; + writer.WriteStringValue(MemberThrottle); + break; case AllocationExplainDecision.No: - writer.WriteStringValue("NO"); - return; + writer.WriteStringValue(MemberNo); + break; case AllocationExplainDecision.Always: - writer.WriteStringValue("ALWAYS"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AllocationExplainDecision)}'."); } - - writer.WriteNullValue(); } } @@ -105,66 +118,94 @@ public enum Decision AllocationDelayed } -internal sealed class DecisionConverter : JsonConverter +internal sealed partial class DecisionConverter : System.Text.Json.Serialization.JsonConverter { - public override Decision Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("yes"); + private static readonly System.Text.Json.JsonEncodedText MemberWorseBalance = System.Text.Json.JsonEncodedText.Encode("worse_balance"); + private static readonly System.Text.Json.JsonEncodedText MemberThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText MemberNoValidShardCopy = System.Text.Json.JsonEncodedText.Encode("no_valid_shard_copy"); + private static readonly System.Text.Json.JsonEncodedText MemberNoAttempt = System.Text.Json.JsonEncodedText.Encode("no_attempt"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberAwaitingInfo = System.Text.Json.JsonEncodedText.Encode("awaiting_info"); + private static readonly System.Text.Json.JsonEncodedText MemberAllocationDelayed = System.Text.Json.JsonEncodedText.Encode("allocation_delayed"); + + public override Decision Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return Decision.Yes; + } + + if (reader.ValueTextEquals(MemberWorseBalance)) { - case "yes": - return Decision.Yes; - case "worse_balance": - return Decision.WorseBalance; - case "throttled": - return Decision.Throttled; - case "no_valid_shard_copy": - return Decision.NoValidShardCopy; - case "no_attempt": - return Decision.NoAttempt; - case "no": - return Decision.No; - case "awaiting_info": - return Decision.AwaitingInfo; - case "allocation_delayed": - return Decision.AllocationDelayed; + return Decision.WorseBalance; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberThrottled)) + { + return Decision.Throttled; + } + + if (reader.ValueTextEquals(MemberNoValidShardCopy)) + { + return Decision.NoValidShardCopy; + } + + if (reader.ValueTextEquals(MemberNoAttempt)) + { + return Decision.NoAttempt; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return Decision.No; + } + + if (reader.ValueTextEquals(MemberAwaitingInfo)) + { + return Decision.AwaitingInfo; + } + + if (reader.ValueTextEquals(MemberAllocationDelayed)) + { + return Decision.AllocationDelayed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Decision)}'."); } - public override void Write(Utf8JsonWriter writer, Decision value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Decision value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Decision.Yes: - writer.WriteStringValue("yes"); - return; + writer.WriteStringValue(MemberYes); + break; case Decision.WorseBalance: - writer.WriteStringValue("worse_balance"); - return; + writer.WriteStringValue(MemberWorseBalance); + break; case Decision.Throttled: - writer.WriteStringValue("throttled"); - return; + writer.WriteStringValue(MemberThrottled); + break; case Decision.NoValidShardCopy: - writer.WriteStringValue("no_valid_shard_copy"); - return; + writer.WriteStringValue(MemberNoValidShardCopy); + break; case Decision.NoAttempt: - writer.WriteStringValue("no_attempt"); - return; + writer.WriteStringValue(MemberNoAttempt); + break; case Decision.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case Decision.AwaitingInfo: - writer.WriteStringValue("awaiting_info"); - return; + writer.WriteStringValue(MemberAwaitingInfo); + break; case Decision.AllocationDelayed: - writer.WriteStringValue("allocation_delayed"); - return; + writer.WriteStringValue(MemberAllocationDelayed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Decision)}'."); } - - writer.WriteNullValue(); } } @@ -203,100 +244,156 @@ public enum UnassignedInformationReason AllocationFailed } -internal sealed class UnassignedInformationReasonConverter : JsonConverter +internal sealed partial class UnassignedInformationReasonConverter : System.Text.Json.Serialization.JsonConverter { - public override UnassignedInformationReason Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRerouteCancelled = System.Text.Json.JsonEncodedText.Encode("REROUTE_CANCELLED"); + private static readonly System.Text.Json.JsonEncodedText MemberReplicaAdded = System.Text.Json.JsonEncodedText.Encode("REPLICA_ADDED"); + private static readonly System.Text.Json.JsonEncodedText MemberReinitialized = System.Text.Json.JsonEncodedText.Encode("REINITIALIZED"); + private static readonly System.Text.Json.JsonEncodedText MemberReallocatedReplica = System.Text.Json.JsonEncodedText.Encode("REALLOCATED_REPLICA"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimaryFailed = System.Text.Json.JsonEncodedText.Encode("PRIMARY_FAILED"); + private static readonly System.Text.Json.JsonEncodedText MemberNodeLeft = System.Text.Json.JsonEncodedText.Encode("NODE_LEFT"); + private static readonly System.Text.Json.JsonEncodedText MemberNewIndexRestored = System.Text.Json.JsonEncodedText.Encode("NEW_INDEX_RESTORED"); + private static readonly System.Text.Json.JsonEncodedText MemberManualAllocation = System.Text.Json.JsonEncodedText.Encode("MANUAL_ALLOCATION"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexReopened = System.Text.Json.JsonEncodedText.Encode("INDEX_REOPENED"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexCreated = System.Text.Json.JsonEncodedText.Encode("INDEX_CREATED"); + private static readonly System.Text.Json.JsonEncodedText MemberForcedEmptyPrimary = System.Text.Json.JsonEncodedText.Encode("FORCED_EMPTY_PRIMARY"); + private static readonly System.Text.Json.JsonEncodedText MemberExistingIndexRestored = System.Text.Json.JsonEncodedText.Encode("EXISTING_INDEX_RESTORED"); + private static readonly System.Text.Json.JsonEncodedText MemberDanglingIndexImported = System.Text.Json.JsonEncodedText.Encode("DANGLING_INDEX_IMPORTED"); + private static readonly System.Text.Json.JsonEncodedText MemberClusterRecovered = System.Text.Json.JsonEncodedText.Encode("CLUSTER_RECOVERED"); + private static readonly System.Text.Json.JsonEncodedText MemberAllocationFailed = System.Text.Json.JsonEncodedText.Encode("ALLOCATION_FAILED"); + + public override UnassignedInformationReason Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRerouteCancelled)) + { + return UnassignedInformationReason.RerouteCancelled; + } + + if (reader.ValueTextEquals(MemberReplicaAdded)) + { + return UnassignedInformationReason.ReplicaAdded; + } + + if (reader.ValueTextEquals(MemberReinitialized)) + { + return UnassignedInformationReason.Reinitialized; + } + + if (reader.ValueTextEquals(MemberReallocatedReplica)) + { + return UnassignedInformationReason.ReallocatedReplica; + } + + if (reader.ValueTextEquals(MemberPrimaryFailed)) + { + return UnassignedInformationReason.PrimaryFailed; + } + + if (reader.ValueTextEquals(MemberNodeLeft)) + { + return UnassignedInformationReason.NodeLeft; + } + + if (reader.ValueTextEquals(MemberNewIndexRestored)) + { + return UnassignedInformationReason.NewIndexRestored; + } + + if (reader.ValueTextEquals(MemberManualAllocation)) + { + return UnassignedInformationReason.ManualAllocation; + } + + if (reader.ValueTextEquals(MemberIndexReopened)) { - case "REROUTE_CANCELLED": - return UnassignedInformationReason.RerouteCancelled; - case "REPLICA_ADDED": - return UnassignedInformationReason.ReplicaAdded; - case "REINITIALIZED": - return UnassignedInformationReason.Reinitialized; - case "REALLOCATED_REPLICA": - return UnassignedInformationReason.ReallocatedReplica; - case "PRIMARY_FAILED": - return UnassignedInformationReason.PrimaryFailed; - case "NODE_LEFT": - return UnassignedInformationReason.NodeLeft; - case "NEW_INDEX_RESTORED": - return UnassignedInformationReason.NewIndexRestored; - case "MANUAL_ALLOCATION": - return UnassignedInformationReason.ManualAllocation; - case "INDEX_REOPENED": - return UnassignedInformationReason.IndexReopened; - case "INDEX_CREATED": - return UnassignedInformationReason.IndexCreated; - case "FORCED_EMPTY_PRIMARY": - return UnassignedInformationReason.ForcedEmptyPrimary; - case "EXISTING_INDEX_RESTORED": - return UnassignedInformationReason.ExistingIndexRestored; - case "DANGLING_INDEX_IMPORTED": - return UnassignedInformationReason.DanglingIndexImported; - case "CLUSTER_RECOVERED": - return UnassignedInformationReason.ClusterRecovered; - case "ALLOCATION_FAILED": - return UnassignedInformationReason.AllocationFailed; + return UnassignedInformationReason.IndexReopened; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberIndexCreated)) + { + return UnassignedInformationReason.IndexCreated; + } + + if (reader.ValueTextEquals(MemberForcedEmptyPrimary)) + { + return UnassignedInformationReason.ForcedEmptyPrimary; + } + + if (reader.ValueTextEquals(MemberExistingIndexRestored)) + { + return UnassignedInformationReason.ExistingIndexRestored; + } + + if (reader.ValueTextEquals(MemberDanglingIndexImported)) + { + return UnassignedInformationReason.DanglingIndexImported; + } + + if (reader.ValueTextEquals(MemberClusterRecovered)) + { + return UnassignedInformationReason.ClusterRecovered; + } + + if (reader.ValueTextEquals(MemberAllocationFailed)) + { + return UnassignedInformationReason.AllocationFailed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(UnassignedInformationReason)}'."); } - public override void Write(Utf8JsonWriter writer, UnassignedInformationReason value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnassignedInformationReason value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case UnassignedInformationReason.RerouteCancelled: - writer.WriteStringValue("REROUTE_CANCELLED"); - return; + writer.WriteStringValue(MemberRerouteCancelled); + break; case UnassignedInformationReason.ReplicaAdded: - writer.WriteStringValue("REPLICA_ADDED"); - return; + writer.WriteStringValue(MemberReplicaAdded); + break; case UnassignedInformationReason.Reinitialized: - writer.WriteStringValue("REINITIALIZED"); - return; + writer.WriteStringValue(MemberReinitialized); + break; case UnassignedInformationReason.ReallocatedReplica: - writer.WriteStringValue("REALLOCATED_REPLICA"); - return; + writer.WriteStringValue(MemberReallocatedReplica); + break; case UnassignedInformationReason.PrimaryFailed: - writer.WriteStringValue("PRIMARY_FAILED"); - return; + writer.WriteStringValue(MemberPrimaryFailed); + break; case UnassignedInformationReason.NodeLeft: - writer.WriteStringValue("NODE_LEFT"); - return; + writer.WriteStringValue(MemberNodeLeft); + break; case UnassignedInformationReason.NewIndexRestored: - writer.WriteStringValue("NEW_INDEX_RESTORED"); - return; + writer.WriteStringValue(MemberNewIndexRestored); + break; case UnassignedInformationReason.ManualAllocation: - writer.WriteStringValue("MANUAL_ALLOCATION"); - return; + writer.WriteStringValue(MemberManualAllocation); + break; case UnassignedInformationReason.IndexReopened: - writer.WriteStringValue("INDEX_REOPENED"); - return; + writer.WriteStringValue(MemberIndexReopened); + break; case UnassignedInformationReason.IndexCreated: - writer.WriteStringValue("INDEX_CREATED"); - return; + writer.WriteStringValue(MemberIndexCreated); + break; case UnassignedInformationReason.ForcedEmptyPrimary: - writer.WriteStringValue("FORCED_EMPTY_PRIMARY"); - return; + writer.WriteStringValue(MemberForcedEmptyPrimary); + break; case UnassignedInformationReason.ExistingIndexRestored: - writer.WriteStringValue("EXISTING_INDEX_RESTORED"); - return; + writer.WriteStringValue(MemberExistingIndexRestored); + break; case UnassignedInformationReason.DanglingIndexImported: - writer.WriteStringValue("DANGLING_INDEX_IMPORTED"); - return; + writer.WriteStringValue(MemberDanglingIndexImported); + break; case UnassignedInformationReason.ClusterRecovered: - writer.WriteStringValue("CLUSTER_RECOVERED"); - return; + writer.WriteStringValue(MemberClusterRecovered); + break; case UnassignedInformationReason.AllocationFailed: - writer.WriteStringValue("ALLOCATION_FAILED"); - return; + writer.WriteStringValue(MemberAllocationFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(UnassignedInformationReason)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs index 8752f1368d9..661588984fd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum ImpactArea Backup } -internal sealed class ImpactAreaConverter : JsonConverter +internal sealed partial class ImpactAreaConverter : System.Text.Json.Serialization.JsonConverter { - public override ImpactArea Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberDeploymentManagement = System.Text.Json.JsonEncodedText.Encode("deployment_management"); + private static readonly System.Text.Json.JsonEncodedText MemberBackup = System.Text.Json.JsonEncodedText.Encode("backup"); + + public override ImpactArea Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSearch)) + { + return ImpactArea.Search; + } + + if (reader.ValueTextEquals(MemberIngest)) { - case "search": - return ImpactArea.Search; - case "ingest": - return ImpactArea.Ingest; - case "deployment_management": - return ImpactArea.DeploymentManagement; - case "backup": - return ImpactArea.Backup; + return ImpactArea.Ingest; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDeploymentManagement)) + { + return ImpactArea.DeploymentManagement; + } + + if (reader.ValueTextEquals(MemberBackup)) + { + return ImpactArea.Backup; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ImpactArea)}'."); } - public override void Write(Utf8JsonWriter writer, ImpactArea value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ImpactArea value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ImpactArea.Search: - writer.WriteStringValue("search"); - return; + writer.WriteStringValue(MemberSearch); + break; case ImpactArea.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case ImpactArea.DeploymentManagement: - writer.WriteStringValue("deployment_management"); - return; + writer.WriteStringValue(MemberDeploymentManagement); + break; case ImpactArea.Backup: - writer.WriteStringValue("backup"); - return; + writer.WriteStringValue(MemberBackup); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ImpactArea)}'."); } - - writer.WriteNullValue(); } } @@ -97,45 +110,57 @@ public enum IndicatorHealthStatus Green } -internal sealed class IndicatorHealthStatusConverter : JsonConverter +internal sealed partial class IndicatorHealthStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override IndicatorHealthStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYellow = System.Text.Json.JsonEncodedText.Encode("yellow"); + private static readonly System.Text.Json.JsonEncodedText MemberUnknown = System.Text.Json.JsonEncodedText.Encode("unknown"); + private static readonly System.Text.Json.JsonEncodedText MemberRed = System.Text.Json.JsonEncodedText.Encode("red"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen = System.Text.Json.JsonEncodedText.Encode("green"); + + public override IndicatorHealthStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYellow)) + { + return IndicatorHealthStatus.Yellow; + } + + if (reader.ValueTextEquals(MemberUnknown)) { - case "yellow": - return IndicatorHealthStatus.Yellow; - case "unknown": - return IndicatorHealthStatus.Unknown; - case "red": - return IndicatorHealthStatus.Red; - case "green": - return IndicatorHealthStatus.Green; + return IndicatorHealthStatus.Unknown; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRed)) + { + return IndicatorHealthStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen)) + { + return IndicatorHealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndicatorHealthStatus)}'."); } - public override void Write(Utf8JsonWriter writer, IndicatorHealthStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicatorHealthStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndicatorHealthStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case IndicatorHealthStatus.Unknown: - writer.WriteStringValue("unknown"); - return; + writer.WriteStringValue(MemberUnknown); + break; case IndicatorHealthStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case IndicatorHealthStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndicatorHealthStatus)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.Search.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.Search.g.cs index 733910adc3f..53a0310ce1c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.Search.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.Search.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -60,41 +61,49 @@ public enum BoundaryScanner Chars } -internal sealed class BoundaryScannerConverter : JsonConverter +internal sealed partial class BoundaryScannerConverter : System.Text.Json.Serialization.JsonConverter { - public override BoundaryScanner Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWord = System.Text.Json.JsonEncodedText.Encode("word"); + private static readonly System.Text.Json.JsonEncodedText MemberSentence = System.Text.Json.JsonEncodedText.Encode("sentence"); + private static readonly System.Text.Json.JsonEncodedText MemberChars = System.Text.Json.JsonEncodedText.Encode("chars"); + + public override BoundaryScanner Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWord)) { - case "word": - return BoundaryScanner.Word; - case "sentence": - return BoundaryScanner.Sentence; - case "chars": - return BoundaryScanner.Chars; + return BoundaryScanner.Word; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSentence)) + { + return BoundaryScanner.Sentence; + } + + if (reader.ValueTextEquals(MemberChars)) + { + return BoundaryScanner.Chars; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(BoundaryScanner)}'."); } - public override void Write(Utf8JsonWriter writer, BoundaryScanner value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, BoundaryScanner value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case BoundaryScanner.Word: - writer.WriteStringValue("word"); - return; + writer.WriteStringValue(MemberWord); + break; case BoundaryScanner.Sentence: - writer.WriteStringValue("sentence"); - return; + writer.WriteStringValue(MemberSentence); + break; case BoundaryScanner.Chars: - writer.WriteStringValue("chars"); - return; + writer.WriteStringValue(MemberChars); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(BoundaryScanner)}'."); } - - writer.WriteNullValue(); } } @@ -107,36 +116,40 @@ public enum HighlighterEncoder Default } -internal sealed class HighlighterEncoderConverter : JsonConverter +internal sealed partial class HighlighterEncoderConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterEncoder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberHtml = System.Text.Json.JsonEncodedText.Encode("html"); + private static readonly System.Text.Json.JsonEncodedText MemberDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override HighlighterEncoder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberHtml)) { - case "html": - return HighlighterEncoder.Html; - case "default": - return HighlighterEncoder.Default; + return HighlighterEncoder.Html; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDefault)) + { + return HighlighterEncoder.Default; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterEncoder)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterEncoder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterEncoder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterEncoder.Html: - writer.WriteStringValue("html"); - return; + writer.WriteStringValue(MemberHtml); + break; case HighlighterEncoder.Default: - writer.WriteStringValue("default"); - return; + writer.WriteStringValue(MemberDefault); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterEncoder)}'."); } - - writer.WriteNullValue(); } } @@ -149,36 +162,40 @@ public enum HighlighterFragmenter Simple } -internal sealed class HighlighterFragmenterConverter : JsonConverter +internal sealed partial class HighlighterFragmenterConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterFragmenter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpan = System.Text.Json.JsonEncodedText.Encode("span"); + private static readonly System.Text.Json.JsonEncodedText MemberSimple = System.Text.Json.JsonEncodedText.Encode("simple"); + + public override HighlighterFragmenter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpan)) + { + return HighlighterFragmenter.Span; + } + + if (reader.ValueTextEquals(MemberSimple)) { - case "span": - return HighlighterFragmenter.Span; - case "simple": - return HighlighterFragmenter.Simple; + return HighlighterFragmenter.Simple; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterFragmenter)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterFragmenter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterFragmenter value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterFragmenter.Span: - writer.WriteStringValue("span"); - return; + writer.WriteStringValue(MemberSpan); + break; case HighlighterFragmenter.Simple: - writer.WriteStringValue("simple"); - return; + writer.WriteStringValue(MemberSimple); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterFragmenter)}'."); } - - writer.WriteNullValue(); } } @@ -189,31 +206,31 @@ public enum HighlighterOrder Score } -internal sealed class HighlighterOrderConverter : JsonConverter +internal sealed partial class HighlighterOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override HighlighterOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScore)) { - case "score": - return HighlighterOrder.Score; + return HighlighterOrder.Score; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterOrder)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterOrder.Score: - writer.WriteStringValue("score"); - return; + writer.WriteStringValue(MemberScore); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterOrder)}'."); } - - writer.WriteNullValue(); } } @@ -224,31 +241,31 @@ public enum HighlighterTagsSchema Styled } -internal sealed class HighlighterTagsSchemaConverter : JsonConverter +internal sealed partial class HighlighterTagsSchemaConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterTagsSchema Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStyled = System.Text.Json.JsonEncodedText.Encode("styled"); + + public override HighlighterTagsSchema Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStyled)) { - case "styled": - return HighlighterTagsSchema.Styled; + return HighlighterTagsSchema.Styled; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterTagsSchema)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterTagsSchema value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterTagsSchema value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterTagsSchema.Styled: - writer.WriteStringValue("styled"); - return; + writer.WriteStringValue(MemberStyled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterTagsSchema)}'."); } - - writer.WriteNullValue(); } } @@ -256,9 +273,11 @@ public override void Write(Utf8JsonWriter writer, HighlighterTagsSchema value, J public readonly partial struct HighlighterType : IEnumStruct { public HighlighterType(string value) => Value = value; - +#if NET7_0_OR_GREATER + static HighlighterType IEnumStruct.Create(string value) => value; +#else HighlighterType IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -336,51 +355,67 @@ public enum ScoreMode Avg } -internal sealed class ScoreModeConverter : JsonConverter +internal sealed partial class ScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override ScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "total": - return ScoreMode.Total; - case "multiply": - return ScoreMode.Multiply; - case "min": - return ScoreMode.Min; - case "max": - return ScoreMode.Max; - case "avg": - return ScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTotal)) + { + return ScoreMode.Total; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return ScoreMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return ScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return ScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return ScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, ScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ScoreMode.Total: - writer.WriteStringValue("total"); - return; + writer.WriteStringValue(MemberTotal); + break; case ScoreMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case ScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case ScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case ScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -424,51 +459,67 @@ public enum StringDistance DamerauLevenshtein } -internal sealed class StringDistanceConverter : JsonConverter +internal sealed partial class StringDistanceConverter : System.Text.Json.Serialization.JsonConverter { - public override StringDistance Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNgram = System.Text.Json.JsonEncodedText.Encode("ngram"); + private static readonly System.Text.Json.JsonEncodedText MemberLevenshtein = System.Text.Json.JsonEncodedText.Encode("levenshtein"); + private static readonly System.Text.Json.JsonEncodedText MemberJaroWinkler = System.Text.Json.JsonEncodedText.Encode("jaro_winkler"); + private static readonly System.Text.Json.JsonEncodedText MemberInternal = System.Text.Json.JsonEncodedText.Encode("internal"); + private static readonly System.Text.Json.JsonEncodedText MemberDamerauLevenshtein = System.Text.Json.JsonEncodedText.Encode("damerau_levenshtein"); + + public override StringDistance Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "ngram": - return StringDistance.Ngram; - case "levenshtein": - return StringDistance.Levenshtein; - case "jaro_winkler": - return StringDistance.JaroWinkler; - case "internal": - return StringDistance.Internal; - case "damerau_levenshtein": - return StringDistance.DamerauLevenshtein; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNgram)) + { + return StringDistance.Ngram; + } + + if (reader.ValueTextEquals(MemberLevenshtein)) + { + return StringDistance.Levenshtein; + } + + if (reader.ValueTextEquals(MemberJaroWinkler)) + { + return StringDistance.JaroWinkler; + } + + if (reader.ValueTextEquals(MemberInternal)) + { + return StringDistance.Internal; + } + + if (reader.ValueTextEquals(MemberDamerauLevenshtein)) + { + return StringDistance.DamerauLevenshtein; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(StringDistance)}'."); } - public override void Write(Utf8JsonWriter writer, StringDistance value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringDistance value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case StringDistance.Ngram: - writer.WriteStringValue("ngram"); - return; + writer.WriteStringValue(MemberNgram); + break; case StringDistance.Levenshtein: - writer.WriteStringValue("levenshtein"); - return; + writer.WriteStringValue(MemberLevenshtein); + break; case StringDistance.JaroWinkler: - writer.WriteStringValue("jaro_winkler"); - return; + writer.WriteStringValue(MemberJaroWinkler); + break; case StringDistance.Internal: - writer.WriteStringValue("internal"); - return; + writer.WriteStringValue(MemberInternal); + break; case StringDistance.DamerauLevenshtein: - writer.WriteStringValue("damerau_levenshtein"); - return; + writer.WriteStringValue(MemberDamerauLevenshtein); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(StringDistance)}'."); } - - writer.WriteNullValue(); } } @@ -491,36 +542,40 @@ public enum SuggestSort Frequency } -internal sealed class SuggestSortConverter : JsonConverter +internal sealed partial class SuggestSortConverter : System.Text.Json.Serialization.JsonConverter { - public override SuggestSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScore = System.Text.Json.JsonEncodedText.Encode("score"); + private static readonly System.Text.Json.JsonEncodedText MemberFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + + public override SuggestSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScore)) { - case "score": - return SuggestSort.Score; - case "frequency": - return SuggestSort.Frequency; + return SuggestSort.Score; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFrequency)) + { + return SuggestSort.Frequency; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SuggestSort)}'."); } - public override void Write(Utf8JsonWriter writer, SuggestSort value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestSort value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SuggestSort.Score: - writer.WriteStringValue("score"); - return; + writer.WriteStringValue(MemberScore); + break; case SuggestSort.Frequency: - writer.WriteStringValue("frequency"); - return; + writer.WriteStringValue(MemberFrequency); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SuggestSort)}'."); } - - writer.WriteNullValue(); } } @@ -543,35 +598,39 @@ public enum TotalHitsRelation Eq } -internal sealed class TotalHitsRelationConverter : JsonConverter +internal sealed partial class TotalHitsRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override TotalHitsRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberEq = System.Text.Json.JsonEncodedText.Encode("eq"); + + public override TotalHitsRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGte)) { - case "gte": - return TotalHitsRelation.Gte; - case "eq": - return TotalHitsRelation.Eq; + return TotalHitsRelation.Gte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberEq)) + { + return TotalHitsRelation.Eq; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TotalHitsRelation)}'."); } - public override void Write(Utf8JsonWriter writer, TotalHitsRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TotalHitsRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TotalHitsRelation.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case TotalHitsRelation.Eq: - writer.WriteStringValue("eq"); - return; + writer.WriteStringValue(MemberEq); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TotalHitsRelation)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs index 9570d6fe1ff..30cdf80b82d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -37,36 +38,40 @@ public enum GridAggregationType Geohex } -internal sealed class GridAggregationTypeConverter : JsonConverter +internal sealed partial class GridAggregationTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GridAggregationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGeotile = System.Text.Json.JsonEncodedText.Encode("geotile"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohex = System.Text.Json.JsonEncodedText.Encode("geohex"); + + public override GridAggregationType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGeotile)) + { + return GridAggregationType.Geotile; + } + + if (reader.ValueTextEquals(MemberGeohex)) { - case "geotile": - return GridAggregationType.Geotile; - case "geohex": - return GridAggregationType.Geohex; + return GridAggregationType.Geohex; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GridAggregationType)}'."); } - public override void Write(Utf8JsonWriter writer, GridAggregationType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GridAggregationType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GridAggregationType.Geotile: - writer.WriteStringValue("geotile"); - return; + writer.WriteStringValue(MemberGeotile); + break; case GridAggregationType.Geohex: - writer.WriteStringValue("geohex"); - return; + writer.WriteStringValue(MemberGeohex); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GridAggregationType)}'."); } - - writer.WriteNullValue(); } } @@ -81,40 +86,48 @@ public enum GridType Centroid } -internal sealed class GridTypeConverter : JsonConverter +internal sealed partial class GridTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GridType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPoint = System.Text.Json.JsonEncodedText.Encode("point"); + private static readonly System.Text.Json.JsonEncodedText MemberGrid = System.Text.Json.JsonEncodedText.Encode("grid"); + private static readonly System.Text.Json.JsonEncodedText MemberCentroid = System.Text.Json.JsonEncodedText.Encode("centroid"); + + public override GridType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPoint)) { - case "point": - return GridType.Point; - case "grid": - return GridType.Grid; - case "centroid": - return GridType.Centroid; + return GridType.Point; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGrid)) + { + return GridType.Grid; + } + + if (reader.ValueTextEquals(MemberCentroid)) + { + return GridType.Centroid; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GridType)}'."); } - public override void Write(Utf8JsonWriter writer, GridType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GridType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GridType.Point: - writer.WriteStringValue("point"); - return; + writer.WriteStringValue(MemberPoint); + break; case GridType.Grid: - writer.WriteStringValue("grid"); - return; + writer.WriteStringValue(MemberGrid); + break; case GridType.Centroid: - writer.WriteStringValue("centroid"); - return; + writer.WriteStringValue(MemberCentroid); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GridType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Enrich.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Enrich.g.cs index ae03d3ffb09..53679c53667 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Enrich.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Enrich.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum EnrichPolicyPhase Complete } -internal sealed class EnrichPolicyPhaseConverter : JsonConverter +internal sealed partial class EnrichPolicyPhaseConverter : System.Text.Json.Serialization.JsonConverter { - public override EnrichPolicyPhase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScheduled = System.Text.Json.JsonEncodedText.Encode("SCHEDULED"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("RUNNING"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("FAILED"); + private static readonly System.Text.Json.JsonEncodedText MemberComplete = System.Text.Json.JsonEncodedText.Encode("COMPLETE"); + + public override EnrichPolicyPhase Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScheduled)) + { + return EnrichPolicyPhase.Scheduled; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return EnrichPolicyPhase.Running; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return EnrichPolicyPhase.Failed; + } + + if (reader.ValueTextEquals(MemberComplete)) { - case "SCHEDULED": - return EnrichPolicyPhase.Scheduled; - case "RUNNING": - return EnrichPolicyPhase.Running; - case "FAILED": - return EnrichPolicyPhase.Failed; - case "COMPLETE": - return EnrichPolicyPhase.Complete; + return EnrichPolicyPhase.Complete; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EnrichPolicyPhase)}'."); } - public override void Write(Utf8JsonWriter writer, EnrichPolicyPhase value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichPolicyPhase value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EnrichPolicyPhase.Scheduled: - writer.WriteStringValue("SCHEDULED"); - return; + writer.WriteStringValue(MemberScheduled); + break; case EnrichPolicyPhase.Running: - writer.WriteStringValue("RUNNING"); - return; + writer.WriteStringValue(MemberRunning); + break; case EnrichPolicyPhase.Failed: - writer.WriteStringValue("FAILED"); - return; + writer.WriteStringValue(MemberFailed); + break; case EnrichPolicyPhase.Complete: - writer.WriteStringValue("COMPLETE"); - return; + writer.WriteStringValue(MemberComplete); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EnrichPolicyPhase)}'."); } - - writer.WriteNullValue(); } } @@ -95,40 +108,48 @@ public enum PolicyType GeoMatch } -internal sealed class PolicyTypeConverter : JsonConverter +internal sealed partial class PolicyTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PolicyType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText MemberMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoMatch = System.Text.Json.JsonEncodedText.Encode("geo_match"); + + public override PolicyType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRange)) + { + return PolicyType.Range; + } + + if (reader.ValueTextEquals(MemberMatch)) { - case "range": - return PolicyType.Range; - case "match": - return PolicyType.Match; - case "geo_match": - return PolicyType.GeoMatch; + return PolicyType.Match; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeoMatch)) + { + return PolicyType.GeoMatch; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PolicyType)}'."); } - public override void Write(Utf8JsonWriter writer, PolicyType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PolicyType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PolicyType.Range: - writer.WriteStringValue("range"); - return; + writer.WriteStringValue(MemberRange); + break; case PolicyType.Match: - writer.WriteStringValue("match"); - return; + writer.WriteStringValue(MemberMatch); + break; case PolicyType.GeoMatch: - writer.WriteStringValue("geo_match"); - return; + writer.WriteStringValue(MemberGeoMatch); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PolicyType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Eql.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Eql.g.cs index 75e0ada4a0f..0ebb896afa7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Eql.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Eql.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -47,35 +48,39 @@ public enum ResultPosition Head } -internal sealed class ResultPositionConverter : JsonConverter +internal sealed partial class ResultPositionConverter : System.Text.Json.Serialization.JsonConverter { - public override ResultPosition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTail = System.Text.Json.JsonEncodedText.Encode("tail"); + private static readonly System.Text.Json.JsonEncodedText MemberHead = System.Text.Json.JsonEncodedText.Encode("head"); + + public override ResultPosition Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTail)) { - case "tail": - return ResultPosition.Tail; - case "head": - return ResultPosition.Head; + return ResultPosition.Tail; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberHead)) + { + return ResultPosition.Head; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ResultPosition)}'."); } - public override void Write(Utf8JsonWriter writer, ResultPosition value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResultPosition value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ResultPosition.Tail: - writer.WriteStringValue("tail"); - return; + writer.WriteStringValue(MemberTail); + break; case ResultPosition.Head: - writer.WriteStringValue("head"); - return; + writer.WriteStringValue(MemberHead); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ResultPosition)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Esql.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Esql.g.cs index 9f3b55c714b..3994b367cca 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Esql.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Esql.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -49,65 +50,93 @@ public enum EsqlFormat Arrow } -internal sealed class EsqlFormatConverter : JsonConverter +internal sealed partial class EsqlFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override EsqlFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYaml = System.Text.Json.JsonEncodedText.Encode("yaml"); + private static readonly System.Text.Json.JsonEncodedText MemberTxt = System.Text.Json.JsonEncodedText.Encode("txt"); + private static readonly System.Text.Json.JsonEncodedText MemberTsv = System.Text.Json.JsonEncodedText.Encode("tsv"); + private static readonly System.Text.Json.JsonEncodedText MemberSmile = System.Text.Json.JsonEncodedText.Encode("smile"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText MemberCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText MemberCbor = System.Text.Json.JsonEncodedText.Encode("cbor"); + private static readonly System.Text.Json.JsonEncodedText MemberArrow = System.Text.Json.JsonEncodedText.Encode("arrow"); + + public override EsqlFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYaml)) + { + return EsqlFormat.Yaml; + } + + if (reader.ValueTextEquals(MemberTxt)) + { + return EsqlFormat.Txt; + } + + if (reader.ValueTextEquals(MemberTsv)) + { + return EsqlFormat.Tsv; + } + + if (reader.ValueTextEquals(MemberSmile)) { - case "yaml": - return EsqlFormat.Yaml; - case "txt": - return EsqlFormat.Txt; - case "tsv": - return EsqlFormat.Tsv; - case "smile": - return EsqlFormat.Smile; - case "json": - return EsqlFormat.Json; - case "csv": - return EsqlFormat.Csv; - case "cbor": - return EsqlFormat.Cbor; - case "arrow": - return EsqlFormat.Arrow; + return EsqlFormat.Smile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return EsqlFormat.Json; + } + + if (reader.ValueTextEquals(MemberCsv)) + { + return EsqlFormat.Csv; + } + + if (reader.ValueTextEquals(MemberCbor)) + { + return EsqlFormat.Cbor; + } + + if (reader.ValueTextEquals(MemberArrow)) + { + return EsqlFormat.Arrow; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EsqlFormat)}'."); } - public override void Write(Utf8JsonWriter writer, EsqlFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EsqlFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EsqlFormat.Yaml: - writer.WriteStringValue("yaml"); - return; + writer.WriteStringValue(MemberYaml); + break; case EsqlFormat.Txt: - writer.WriteStringValue("txt"); - return; + writer.WriteStringValue(MemberTxt); + break; case EsqlFormat.Tsv: - writer.WriteStringValue("tsv"); - return; + writer.WriteStringValue(MemberTsv); + break; case EsqlFormat.Smile: - writer.WriteStringValue("smile"); - return; + writer.WriteStringValue(MemberSmile); + break; case EsqlFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; case EsqlFormat.Csv: - writer.WriteStringValue("csv"); - return; + writer.WriteStringValue(MemberCsv); + break; case EsqlFormat.Cbor: - writer.WriteStringValue("cbor"); - return; + writer.WriteStringValue(MemberCbor); + break; case EsqlFormat.Arrow: - writer.WriteStringValue("arrow"); - return; + writer.WriteStringValue(MemberArrow); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EsqlFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.IndexManagement.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.IndexManagement.g.cs index 8c629226390..8c9686f8685 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.IndexManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.IndexManagement.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -39,41 +40,49 @@ public enum Feature Aliases } -internal sealed class FeatureConverter : JsonConverter +internal sealed partial class FeatureConverter : System.Text.Json.Serialization.JsonConverter { - public override Feature Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText MemberMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText MemberAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + + public override Feature Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSettings)) + { + return Feature.Settings; + } + + if (reader.ValueTextEquals(MemberMappings)) + { + return Feature.Mappings; + } + + if (reader.ValueTextEquals(MemberAliases)) { - case "settings": - return Feature.Settings; - case "mappings": - return Feature.Mappings; - case "aliases": - return Feature.Aliases; + return Feature.Aliases; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Feature)}'."); } - public override void Write(Utf8JsonWriter writer, Feature value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Feature value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Feature.Settings: - writer.WriteStringValue("settings"); - return; + writer.WriteStringValue(MemberSettings); + break; case Feature.Mappings: - writer.WriteStringValue("mappings"); - return; + writer.WriteStringValue(MemberMappings); + break; case Feature.Aliases: - writer.WriteStringValue("aliases"); - return; + writer.WriteStringValue(MemberAliases); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Feature)}'."); } - - writer.WriteNullValue(); } } @@ -88,41 +97,49 @@ public enum IndexCheckOnStartup Checksum } -internal sealed class IndexCheckOnStartupConverter : JsonConverter +internal sealed partial class IndexCheckOnStartupConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexCheckOnStartup Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrue = System.Text.Json.JsonEncodedText.Encode("true"); + private static readonly System.Text.Json.JsonEncodedText MemberFalse = System.Text.Json.JsonEncodedText.Encode("false"); + private static readonly System.Text.Json.JsonEncodedText MemberChecksum = System.Text.Json.JsonEncodedText.Encode("checksum"); + + public override IndexCheckOnStartup Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrue)) + { + return IndexCheckOnStartup.True; + } + + if (reader.ValueTextEquals(MemberFalse)) { - case "true": - return IndexCheckOnStartup.True; - case "false": - return IndexCheckOnStartup.False; - case "checksum": - return IndexCheckOnStartup.Checksum; + return IndexCheckOnStartup.False; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberChecksum)) + { + return IndexCheckOnStartup.Checksum; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexCheckOnStartup)}'."); } - public override void Write(Utf8JsonWriter writer, IndexCheckOnStartup value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexCheckOnStartup value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexCheckOnStartup.True: - writer.WriteStringValue("true"); - return; + writer.WriteStringValue(MemberTrue); + break; case IndexCheckOnStartup.False: - writer.WriteStringValue("false"); - return; + writer.WriteStringValue(MemberFalse); + break; case IndexCheckOnStartup.Checksum: - writer.WriteStringValue("checksum"); - return; + writer.WriteStringValue(MemberChecksum); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexCheckOnStartup)}'."); } - - writer.WriteNullValue(); } } @@ -135,36 +152,40 @@ public enum IndexMetadataState Close } -internal sealed class IndexMetadataStateConverter : JsonConverter +internal sealed partial class IndexMetadataStateConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexMetadataState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpen = System.Text.Json.JsonEncodedText.Encode("open"); + private static readonly System.Text.Json.JsonEncodedText MemberClose = System.Text.Json.JsonEncodedText.Encode("close"); + + public override IndexMetadataState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpen)) { - case "open": - return IndexMetadataState.Open; - case "close": - return IndexMetadataState.Close; + return IndexMetadataState.Open; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberClose)) + { + return IndexMetadataState.Close; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexMetadataState)}'."); } - public override void Write(Utf8JsonWriter writer, IndexMetadataState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexMetadataState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexMetadataState.Open: - writer.WriteStringValue("open"); - return; + writer.WriteStringValue(MemberOpen); + break; case IndexMetadataState.Close: - writer.WriteStringValue("close"); - return; + writer.WriteStringValue(MemberClose); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexMetadataState)}'."); } - - writer.WriteNullValue(); } } @@ -181,46 +202,58 @@ public enum IndexRoutingAllocationOptions All } -internal sealed class IndexRoutingAllocationOptionsConverter : JsonConverter +internal sealed partial class IndexRoutingAllocationOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexRoutingAllocationOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPrimaries = System.Text.Json.JsonEncodedText.Encode("primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNewPrimaries = System.Text.Json.JsonEncodedText.Encode("new_primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override IndexRoutingAllocationOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPrimaries)) { - case "primaries": - return IndexRoutingAllocationOptions.Primaries; - case "none": - return IndexRoutingAllocationOptions.None; - case "new_primaries": - return IndexRoutingAllocationOptions.NewPrimaries; - case "all": - return IndexRoutingAllocationOptions.All; + return IndexRoutingAllocationOptions.Primaries; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNone)) + { + return IndexRoutingAllocationOptions.None; + } + + if (reader.ValueTextEquals(MemberNewPrimaries)) + { + return IndexRoutingAllocationOptions.NewPrimaries; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return IndexRoutingAllocationOptions.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexRoutingAllocationOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexRoutingAllocationOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexRoutingAllocationOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexRoutingAllocationOptions.Primaries: - writer.WriteStringValue("primaries"); - return; + writer.WriteStringValue(MemberPrimaries); + break; case IndexRoutingAllocationOptions.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case IndexRoutingAllocationOptions.NewPrimaries: - writer.WriteStringValue("new_primaries"); - return; + writer.WriteStringValue(MemberNewPrimaries); + break; case IndexRoutingAllocationOptions.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexRoutingAllocationOptions)}'."); } - - writer.WriteNullValue(); } } @@ -237,46 +270,58 @@ public enum IndexRoutingRebalanceOptions All } -internal sealed class IndexRoutingRebalanceOptionsConverter : JsonConverter +internal sealed partial class IndexRoutingRebalanceOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexRoutingRebalanceOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReplicas = System.Text.Json.JsonEncodedText.Encode("replicas"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimaries = System.Text.Json.JsonEncodedText.Encode("primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override IndexRoutingRebalanceOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReplicas)) + { + return IndexRoutingRebalanceOptions.Replicas; + } + + if (reader.ValueTextEquals(MemberPrimaries)) + { + return IndexRoutingRebalanceOptions.Primaries; + } + + if (reader.ValueTextEquals(MemberNone)) { - case "replicas": - return IndexRoutingRebalanceOptions.Replicas; - case "primaries": - return IndexRoutingRebalanceOptions.Primaries; - case "none": - return IndexRoutingRebalanceOptions.None; - case "all": - return IndexRoutingRebalanceOptions.All; + return IndexRoutingRebalanceOptions.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAll)) + { + return IndexRoutingRebalanceOptions.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexRoutingRebalanceOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexRoutingRebalanceOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexRoutingRebalanceOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexRoutingRebalanceOptions.Replicas: - writer.WriteStringValue("replicas"); - return; + writer.WriteStringValue(MemberReplicas); + break; case IndexRoutingRebalanceOptions.Primaries: - writer.WriteStringValue("primaries"); - return; + writer.WriteStringValue(MemberPrimaries); + break; case IndexRoutingRebalanceOptions.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case IndexRoutingRebalanceOptions.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexRoutingRebalanceOptions)}'."); } - - writer.WriteNullValue(); } } @@ -291,41 +336,49 @@ public enum ManagedBy Datastream } -internal sealed class ManagedByConverter : JsonConverter +internal sealed partial class ManagedByConverter : System.Text.Json.Serialization.JsonConverter { - public override ManagedBy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnmanaged = System.Text.Json.JsonEncodedText.Encode("Unmanaged"); + private static readonly System.Text.Json.JsonEncodedText MemberIlm = System.Text.Json.JsonEncodedText.Encode("Index Lifecycle Management"); + private static readonly System.Text.Json.JsonEncodedText MemberDatastream = System.Text.Json.JsonEncodedText.Encode("Data stream lifecycle"); + + public override ManagedBy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUnmanaged)) { - case "Unmanaged": - return ManagedBy.Unmanaged; - case "Index Lifecycle Management": - return ManagedBy.Ilm; - case "Data stream lifecycle": - return ManagedBy.Datastream; + return ManagedBy.Unmanaged; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberIlm)) + { + return ManagedBy.Ilm; + } + + if (reader.ValueTextEquals(MemberDatastream)) + { + return ManagedBy.Datastream; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ManagedBy)}'."); } - public override void Write(Utf8JsonWriter writer, ManagedBy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ManagedBy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ManagedBy.Unmanaged: - writer.WriteStringValue("Unmanaged"); - return; + writer.WriteStringValue(MemberUnmanaged); + break; case ManagedBy.Ilm: - writer.WriteStringValue("Index Lifecycle Management"); - return; + writer.WriteStringValue(MemberIlm); + break; case ManagedBy.Datastream: - writer.WriteStringValue("Data stream lifecycle"); - return; + writer.WriteStringValue(MemberDatastream); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ManagedBy)}'."); } - - writer.WriteNullValue(); } } @@ -338,36 +391,40 @@ public enum NumericFielddataFormat Array } -internal sealed class NumericFielddataFormatConverter : JsonConverter +internal sealed partial class NumericFielddataFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override NumericFielddataFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + private static readonly System.Text.Json.JsonEncodedText MemberArray = System.Text.Json.JsonEncodedText.Encode("array"); + + public override NumericFielddataFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDisabled)) { - case "disabled": - return NumericFielddataFormat.Disabled; - case "array": - return NumericFielddataFormat.Array; + return NumericFielddataFormat.Disabled; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberArray)) + { + return NumericFielddataFormat.Array; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NumericFielddataFormat)}'."); } - public override void Write(Utf8JsonWriter writer, NumericFielddataFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumericFielddataFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NumericFielddataFormat.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; case NumericFielddataFormat.Array: - writer.WriteStringValue("array"); - return; + writer.WriteStringValue(MemberArray); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NumericFielddataFormat)}'."); } - - writer.WriteNullValue(); } } @@ -380,36 +437,40 @@ public enum SegmentSortMissing First } -internal sealed class SegmentSortMissingConverter : JsonConverter +internal sealed partial class SegmentSortMissingConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortMissing Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLast = System.Text.Json.JsonEncodedText.Encode("_last"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("_first"); + + public override SegmentSortMissing Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLast)) + { + return SegmentSortMissing.Last; + } + + if (reader.ValueTextEquals(MemberFirst)) { - case "_last": - return SegmentSortMissing.Last; - case "_first": - return SegmentSortMissing.First; + return SegmentSortMissing.First; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortMissing)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortMissing value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortMissing value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortMissing.Last: - writer.WriteStringValue("_last"); - return; + writer.WriteStringValue(MemberLast); + break; case SegmentSortMissing.First: - writer.WriteStringValue("_first"); - return; + writer.WriteStringValue(MemberFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortMissing)}'."); } - - writer.WriteNullValue(); } } @@ -422,38 +483,42 @@ public enum SegmentSortMode Max } -internal sealed class SegmentSortModeConverter : JsonConverter +internal sealed partial class SegmentSortModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMin1 = System.Text.Json.JsonEncodedText.Encode("MIN"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberMax1 = System.Text.Json.JsonEncodedText.Encode("MAX"); + + public override SegmentSortMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMin) || reader.ValueTextEquals(MemberMin1)) { - case "min": - case "MIN": - return SegmentSortMode.Min; - case "max": - case "MAX": - return SegmentSortMode.Max; + return SegmentSortMode.Min; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberMax) || reader.ValueTextEquals(MemberMax1)) + { + return SegmentSortMode.Max; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortMode)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case SegmentSortMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortMode)}'."); } - - writer.WriteNullValue(); } } @@ -466,38 +531,42 @@ public enum SegmentSortOrder Asc } -internal sealed class SegmentSortOrderConverter : JsonConverter +internal sealed partial class SegmentSortOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDesc = System.Text.Json.JsonEncodedText.Encode("desc"); + private static readonly System.Text.Json.JsonEncodedText MemberDesc1 = System.Text.Json.JsonEncodedText.Encode("DESC"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc = System.Text.Json.JsonEncodedText.Encode("asc"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc1 = System.Text.Json.JsonEncodedText.Encode("ASC"); + + public override SegmentSortOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDesc) || reader.ValueTextEquals(MemberDesc1)) { - case "desc": - case "DESC": - return SegmentSortOrder.Desc; - case "asc": - case "ASC": - return SegmentSortOrder.Asc; + return SegmentSortOrder.Desc; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAsc) || reader.ValueTextEquals(MemberAsc1)) + { + return SegmentSortOrder.Asc; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortOrder)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortOrder.Desc: - writer.WriteStringValue("desc"); - return; + writer.WriteStringValue(MemberDesc); + break; case SegmentSortOrder.Asc: - writer.WriteStringValue("asc"); - return; + writer.WriteStringValue(MemberAsc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortOrder)}'."); } - - writer.WriteNullValue(); } } @@ -514,46 +583,58 @@ public enum ShardRoutingState Initializing } -internal sealed class ShardRoutingStateConverter : JsonConverter +internal sealed partial class ShardRoutingStateConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardRoutingState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnassigned = System.Text.Json.JsonEncodedText.Encode("UNASSIGNED"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("STARTED"); + private static readonly System.Text.Json.JsonEncodedText MemberRelocating = System.Text.Json.JsonEncodedText.Encode("RELOCATING"); + private static readonly System.Text.Json.JsonEncodedText MemberInitializing = System.Text.Json.JsonEncodedText.Encode("INITIALIZING"); + + public override ShardRoutingState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUnassigned)) + { + return ShardRoutingState.Unassigned; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return ShardRoutingState.Started; + } + + if (reader.ValueTextEquals(MemberRelocating)) { - case "UNASSIGNED": - return ShardRoutingState.Unassigned; - case "STARTED": - return ShardRoutingState.Started; - case "RELOCATING": - return ShardRoutingState.Relocating; - case "INITIALIZING": - return ShardRoutingState.Initializing; + return ShardRoutingState.Relocating; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberInitializing)) + { + return ShardRoutingState.Initializing; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardRoutingState)}'."); } - public override void Write(Utf8JsonWriter writer, ShardRoutingState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardRoutingState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardRoutingState.Unassigned: - writer.WriteStringValue("UNASSIGNED"); - return; + writer.WriteStringValue(MemberUnassigned); + break; case ShardRoutingState.Started: - writer.WriteStringValue("STARTED"); - return; + writer.WriteStringValue(MemberStarted); + break; case ShardRoutingState.Relocating: - writer.WriteStringValue("RELOCATING"); - return; + writer.WriteStringValue(MemberRelocating); + break; case ShardRoutingState.Initializing: - writer.WriteStringValue("INITIALIZING"); - return; + writer.WriteStringValue(MemberInitializing); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardRoutingState)}'."); } - - writer.WriteNullValue(); } } @@ -561,9 +642,11 @@ public override void Write(Utf8JsonWriter writer, ShardRoutingState value, JsonS public readonly partial struct StorageType : IEnumStruct { public StorageType(string value) => Value = value; - +#if NET7_0_OR_GREATER + static StorageType IEnumStruct.Create(string value) => value; +#else StorageType IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -636,37 +719,41 @@ public enum TranslogDurability Async } -internal sealed class TranslogDurabilityConverter : JsonConverter +internal sealed partial class TranslogDurabilityConverter : System.Text.Json.Serialization.JsonConverter { - public override TranslogDurability Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRequest = System.Text.Json.JsonEncodedText.Encode("request"); + private static readonly System.Text.Json.JsonEncodedText MemberRequest1 = System.Text.Json.JsonEncodedText.Encode("REQUEST"); + private static readonly System.Text.Json.JsonEncodedText MemberAsync = System.Text.Json.JsonEncodedText.Encode("async"); + private static readonly System.Text.Json.JsonEncodedText MemberAsync1 = System.Text.Json.JsonEncodedText.Encode("ASYNC"); + + public override TranslogDurability Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRequest) || reader.ValueTextEquals(MemberRequest1)) { - case "request": - case "REQUEST": - return TranslogDurability.Request; - case "async": - case "ASYNC": - return TranslogDurability.Async; + return TranslogDurability.Request; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAsync) || reader.ValueTextEquals(MemberAsync1)) + { + return TranslogDurability.Async; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TranslogDurability)}'."); } - public override void Write(Utf8JsonWriter writer, TranslogDurability value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TranslogDurability value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TranslogDurability.Request: - writer.WriteStringValue("request"); - return; + writer.WriteStringValue(MemberRequest); + break; case TranslogDurability.Async: - writer.WriteStringValue("async"); - return; + writer.WriteStringValue(MemberAsync); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TranslogDurability)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Inference.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Inference.g.cs index 2a4deee6213..753f6bc1fb7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Inference.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Inference.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,45 +42,57 @@ public enum TaskType Completion } -internal sealed class TaskTypeConverter : JsonConverter +internal sealed partial class TaskTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TaskType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText MemberSparseEmbedding = System.Text.Json.JsonEncodedText.Encode("sparse_embedding"); + private static readonly System.Text.Json.JsonEncodedText MemberRerank = System.Text.Json.JsonEncodedText.Encode("rerank"); + private static readonly System.Text.Json.JsonEncodedText MemberCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + + public override TaskType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTextEmbedding)) + { + return TaskType.TextEmbedding; + } + + if (reader.ValueTextEquals(MemberSparseEmbedding)) { - case "text_embedding": - return TaskType.TextEmbedding; - case "sparse_embedding": - return TaskType.SparseEmbedding; - case "rerank": - return TaskType.Rerank; - case "completion": - return TaskType.Completion; + return TaskType.SparseEmbedding; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRerank)) + { + return TaskType.Rerank; + } + + if (reader.ValueTextEquals(MemberCompletion)) + { + return TaskType.Completion; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TaskType)}'."); } - public override void Write(Utf8JsonWriter writer, TaskType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TaskType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TaskType.TextEmbedding: - writer.WriteStringValue("text_embedding"); - return; + writer.WriteStringValue(MemberTextEmbedding); + break; case TaskType.SparseEmbedding: - writer.WriteStringValue("sparse_embedding"); - return; + writer.WriteStringValue(MemberSparseEmbedding); + break; case TaskType.Rerank: - writer.WriteStringValue("rerank"); - return; + writer.WriteStringValue(MemberRerank); + break; case TaskType.Completion: - writer.WriteStringValue("completion"); - return; + writer.WriteStringValue(MemberCompletion); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TaskType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Ingest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Ingest.g.cs index 81ceefaf2ce..7c47962d9f8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Ingest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Ingest.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -49,66 +50,94 @@ public enum ConvertType Auto } -internal sealed class ConvertTypeConverter : JsonConverter +internal sealed partial class ConvertTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ConvertType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("integer"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override ConvertType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "string": - return ConvertType.String; - case "long": - return ConvertType.Long; - case "ip": - return ConvertType.Ip; - case "integer": - return ConvertType.Integer; - case "float": - return ConvertType.Float; - case "double": - return ConvertType.Double; - case "boolean": - return ConvertType.Boolean; - case "auto": - return ConvertType.Auto; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) + { + return ConvertType.String; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return ConvertType.Long; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return ConvertType.Ip; + } + + if (reader.ValueTextEquals(MemberInteger)) + { + return ConvertType.Integer; + } + + if (reader.ValueTextEquals(MemberFloat)) + { + return ConvertType.Float; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return ConvertType.Double; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return ConvertType.Boolean; + } + + if (reader.ValueTextEquals(MemberAuto)) + { + return ConvertType.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ConvertType)}'."); } - public override void Write(Utf8JsonWriter writer, ConvertType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ConvertType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ConvertType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ConvertType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case ConvertType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case ConvertType.Integer: - writer.WriteStringValue("integer"); - return; + writer.WriteStringValue(MemberInteger); + break; case ConvertType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case ConvertType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case ConvertType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; case ConvertType.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ConvertType)}'."); } - - writer.WriteNullValue(); } } @@ -127,51 +156,67 @@ public enum FingerprintDigest Md5 } -internal sealed class FingerprintDigestConverter : JsonConverter +internal sealed partial class FingerprintDigestConverter : System.Text.Json.Serialization.JsonConverter { - public override FingerprintDigest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSha512 = System.Text.Json.JsonEncodedText.Encode("SHA-512"); + private static readonly System.Text.Json.JsonEncodedText MemberSha256 = System.Text.Json.JsonEncodedText.Encode("SHA-256"); + private static readonly System.Text.Json.JsonEncodedText MemberSha1 = System.Text.Json.JsonEncodedText.Encode("SHA-1"); + private static readonly System.Text.Json.JsonEncodedText MemberMurmurhash3 = System.Text.Json.JsonEncodedText.Encode("MurmurHash3"); + private static readonly System.Text.Json.JsonEncodedText MemberMd5 = System.Text.Json.JsonEncodedText.Encode("MD5"); + + public override FingerprintDigest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "SHA-512": - return FingerprintDigest.Sha512; - case "SHA-256": - return FingerprintDigest.Sha256; - case "SHA-1": - return FingerprintDigest.Sha1; - case "MurmurHash3": - return FingerprintDigest.Murmurhash3; - case "MD5": - return FingerprintDigest.Md5; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSha512)) + { + return FingerprintDigest.Sha512; + } + + if (reader.ValueTextEquals(MemberSha256)) + { + return FingerprintDigest.Sha256; + } + + if (reader.ValueTextEquals(MemberSha1)) + { + return FingerprintDigest.Sha1; + } + + if (reader.ValueTextEquals(MemberMurmurhash3)) + { + return FingerprintDigest.Murmurhash3; + } + + if (reader.ValueTextEquals(MemberMd5)) + { + return FingerprintDigest.Md5; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FingerprintDigest)}'."); } - public override void Write(Utf8JsonWriter writer, FingerprintDigest value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintDigest value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FingerprintDigest.Sha512: - writer.WriteStringValue("SHA-512"); - return; + writer.WriteStringValue(MemberSha512); + break; case FingerprintDigest.Sha256: - writer.WriteStringValue("SHA-256"); - return; + writer.WriteStringValue(MemberSha256); + break; case FingerprintDigest.Sha1: - writer.WriteStringValue("SHA-1"); - return; + writer.WriteStringValue(MemberSha1); + break; case FingerprintDigest.Murmurhash3: - writer.WriteStringValue("MurmurHash3"); - return; + writer.WriteStringValue(MemberMurmurhash3); + break; case FingerprintDigest.Md5: - writer.WriteStringValue("MD5"); - return; + writer.WriteStringValue(MemberMd5); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FingerprintDigest)}'."); } - - writer.WriteNullValue(); } } @@ -184,36 +229,40 @@ public enum GeoGridTargetFormat Geojson } -internal sealed class GeoGridTargetFormatConverter : JsonConverter +internal sealed partial class GeoGridTargetFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoGridTargetFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWkt = System.Text.Json.JsonEncodedText.Encode("wkt"); + private static readonly System.Text.Json.JsonEncodedText MemberGeojson = System.Text.Json.JsonEncodedText.Encode("geojson"); + + public override GeoGridTargetFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWkt)) + { + return GeoGridTargetFormat.Wkt; + } + + if (reader.ValueTextEquals(MemberGeojson)) { - case "wkt": - return GeoGridTargetFormat.Wkt; - case "geojson": - return GeoGridTargetFormat.Geojson; + return GeoGridTargetFormat.Geojson; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoGridTargetFormat)}'."); } - public override void Write(Utf8JsonWriter writer, GeoGridTargetFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoGridTargetFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoGridTargetFormat.Wkt: - writer.WriteStringValue("wkt"); - return; + writer.WriteStringValue(MemberWkt); + break; case GeoGridTargetFormat.Geojson: - writer.WriteStringValue("geojson"); - return; + writer.WriteStringValue(MemberGeojson); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoGridTargetFormat)}'."); } - - writer.WriteNullValue(); } } @@ -228,41 +277,49 @@ public enum GeoGridTileType Geohash } -internal sealed class GeoGridTileTypeConverter : JsonConverter +internal sealed partial class GeoGridTileTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoGridTileType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGeotile = System.Text.Json.JsonEncodedText.Encode("geotile"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohex = System.Text.Json.JsonEncodedText.Encode("geohex"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohash = System.Text.Json.JsonEncodedText.Encode("geohash"); + + public override GeoGridTileType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGeotile)) { - case "geotile": - return GeoGridTileType.Geotile; - case "geohex": - return GeoGridTileType.Geohex; - case "geohash": - return GeoGridTileType.Geohash; + return GeoGridTileType.Geotile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeohex)) + { + return GeoGridTileType.Geohex; + } + + if (reader.ValueTextEquals(MemberGeohash)) + { + return GeoGridTileType.Geohash; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoGridTileType)}'."); } - public override void Write(Utf8JsonWriter writer, GeoGridTileType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoGridTileType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoGridTileType.Geotile: - writer.WriteStringValue("geotile"); - return; + writer.WriteStringValue(MemberGeotile); + break; case GeoGridTileType.Geohex: - writer.WriteStringValue("geohex"); - return; + writer.WriteStringValue(MemberGeohex); + break; case GeoGridTileType.Geohash: - writer.WriteStringValue("geohash"); - return; + writer.WriteStringValue(MemberGeohash); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoGridTileType)}'."); } - - writer.WriteNullValue(); } } @@ -285,36 +342,40 @@ public enum JsonProcessorConflictStrategy Merge } -internal sealed class JsonProcessorConflictStrategyConverter : JsonConverter +internal sealed partial class JsonProcessorConflictStrategyConverter : System.Text.Json.Serialization.JsonConverter { - public override JsonProcessorConflictStrategy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText MemberMerge = System.Text.Json.JsonEncodedText.Encode("merge"); + + public override JsonProcessorConflictStrategy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReplace)) + { + return JsonProcessorConflictStrategy.Replace; + } + + if (reader.ValueTextEquals(MemberMerge)) { - case "replace": - return JsonProcessorConflictStrategy.Replace; - case "merge": - return JsonProcessorConflictStrategy.Merge; + return JsonProcessorConflictStrategy.Merge; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JsonProcessorConflictStrategy)}'."); } - public override void Write(Utf8JsonWriter writer, JsonProcessorConflictStrategy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JsonProcessorConflictStrategy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JsonProcessorConflictStrategy.Replace: - writer.WriteStringValue("replace"); - return; + writer.WriteStringValue(MemberReplace); + break; case JsonProcessorConflictStrategy.Merge: - writer.WriteStringValue("merge"); - return; + writer.WriteStringValue(MemberMerge); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JsonProcessorConflictStrategy)}'."); } - - writer.WriteNullValue(); } } @@ -327,36 +388,40 @@ public enum ShapeType GeoShape } -internal sealed class ShapeTypeConverter : JsonConverter +internal sealed partial class ShapeTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ShapeType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + + public override ShapeType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShape)) { - case "shape": - return ShapeType.Shape; - case "geo_shape": - return ShapeType.GeoShape; + return ShapeType.Shape; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeoShape)) + { + return ShapeType.GeoShape; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShapeType)}'."); } - public override void Write(Utf8JsonWriter writer, ShapeType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShapeType.Shape: - writer.WriteStringValue("shape"); - return; + writer.WriteStringValue(MemberShape); + break; case ShapeType.GeoShape: - writer.WriteStringValue("geo_shape"); - return; + writer.WriteStringValue(MemberGeoShape); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShapeType)}'."); } - - writer.WriteNullValue(); } } @@ -375,50 +440,66 @@ public enum UserAgentProperty Device } -internal sealed class UserAgentPropertyConverter : JsonConverter +internal sealed partial class UserAgentPropertyConverter : System.Text.Json.Serialization.JsonConverter { - public override UserAgentProperty Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberOs = System.Text.Json.JsonEncodedText.Encode("os"); + private static readonly System.Text.Json.JsonEncodedText MemberOriginal = System.Text.Json.JsonEncodedText.Encode("original"); + private static readonly System.Text.Json.JsonEncodedText MemberName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText MemberDevice = System.Text.Json.JsonEncodedText.Encode("device"); + + public override UserAgentProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "version": - return UserAgentProperty.Version; - case "os": - return UserAgentProperty.Os; - case "original": - return UserAgentProperty.Original; - case "name": - return UserAgentProperty.Name; - case "device": - return UserAgentProperty.Device; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return UserAgentProperty.Version; + } + + if (reader.ValueTextEquals(MemberOs)) + { + return UserAgentProperty.Os; + } + + if (reader.ValueTextEquals(MemberOriginal)) + { + return UserAgentProperty.Original; + } + + if (reader.ValueTextEquals(MemberName)) + { + return UserAgentProperty.Name; + } + + if (reader.ValueTextEquals(MemberDevice)) + { + return UserAgentProperty.Device; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(UserAgentProperty)}'."); } - public override void Write(Utf8JsonWriter writer, UserAgentProperty value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UserAgentProperty value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case UserAgentProperty.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case UserAgentProperty.Os: - writer.WriteStringValue("os"); - return; + writer.WriteStringValue(MemberOs); + break; case UserAgentProperty.Original: - writer.WriteStringValue("original"); - return; + writer.WriteStringValue(MemberOriginal); + break; case UserAgentProperty.Name: - writer.WriteStringValue("name"); - return; + writer.WriteStringValue(MemberName); + break; case UserAgentProperty.Device: - writer.WriteStringValue("device"); - return; + writer.WriteStringValue(MemberDevice); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(UserAgentProperty)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.LicenseManagement.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.LicenseManagement.g.cs index 70a028f6e76..327cfee06d4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.LicenseManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.LicenseManagement.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum LicenseStatus Active } -internal sealed class LicenseStatusConverter : JsonConverter +internal sealed partial class LicenseStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override LicenseStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberValid = System.Text.Json.JsonEncodedText.Encode("valid"); + private static readonly System.Text.Json.JsonEncodedText MemberInvalid = System.Text.Json.JsonEncodedText.Encode("invalid"); + private static readonly System.Text.Json.JsonEncodedText MemberExpired = System.Text.Json.JsonEncodedText.Encode("expired"); + private static readonly System.Text.Json.JsonEncodedText MemberActive = System.Text.Json.JsonEncodedText.Encode("active"); + + public override LicenseStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberValid)) + { + return LicenseStatus.Valid; + } + + if (reader.ValueTextEquals(MemberInvalid)) + { + return LicenseStatus.Invalid; + } + + if (reader.ValueTextEquals(MemberExpired)) + { + return LicenseStatus.Expired; + } + + if (reader.ValueTextEquals(MemberActive)) { - case "valid": - return LicenseStatus.Valid; - case "invalid": - return LicenseStatus.Invalid; - case "expired": - return LicenseStatus.Expired; - case "active": - return LicenseStatus.Active; + return LicenseStatus.Active; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LicenseStatus)}'."); } - public override void Write(Utf8JsonWriter writer, LicenseStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LicenseStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LicenseStatus.Valid: - writer.WriteStringValue("valid"); - return; + writer.WriteStringValue(MemberValid); + break; case LicenseStatus.Invalid: - writer.WriteStringValue("invalid"); - return; + writer.WriteStringValue(MemberInvalid); + break; case LicenseStatus.Expired: - writer.WriteStringValue("expired"); - return; + writer.WriteStringValue(MemberExpired); + break; case LicenseStatus.Active: - writer.WriteStringValue("active"); - return; + writer.WriteStringValue(MemberActive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LicenseStatus)}'."); } - - writer.WriteNullValue(); } } @@ -107,70 +120,102 @@ public enum LicenseType Basic } -internal sealed class LicenseTypeConverter : JsonConverter +internal sealed partial class LicenseTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override LicenseType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrial = System.Text.Json.JsonEncodedText.Encode("trial"); + private static readonly System.Text.Json.JsonEncodedText MemberStandard = System.Text.Json.JsonEncodedText.Encode("standard"); + private static readonly System.Text.Json.JsonEncodedText MemberSilver = System.Text.Json.JsonEncodedText.Encode("silver"); + private static readonly System.Text.Json.JsonEncodedText MemberPlatinum = System.Text.Json.JsonEncodedText.Encode("platinum"); + private static readonly System.Text.Json.JsonEncodedText MemberMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText MemberGold = System.Text.Json.JsonEncodedText.Encode("gold"); + private static readonly System.Text.Json.JsonEncodedText MemberEnterprise = System.Text.Json.JsonEncodedText.Encode("enterprise"); + private static readonly System.Text.Json.JsonEncodedText MemberDev = System.Text.Json.JsonEncodedText.Encode("dev"); + private static readonly System.Text.Json.JsonEncodedText MemberBasic = System.Text.Json.JsonEncodedText.Encode("basic"); + + public override LicenseType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrial)) + { + return LicenseType.Trial; + } + + if (reader.ValueTextEquals(MemberStandard)) { - case "trial": - return LicenseType.Trial; - case "standard": - return LicenseType.Standard; - case "silver": - return LicenseType.Silver; - case "platinum": - return LicenseType.Platinum; - case "missing": - return LicenseType.Missing; - case "gold": - return LicenseType.Gold; - case "enterprise": - return LicenseType.Enterprise; - case "dev": - return LicenseType.Dev; - case "basic": - return LicenseType.Basic; + return LicenseType.Standard; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSilver)) + { + return LicenseType.Silver; + } + + if (reader.ValueTextEquals(MemberPlatinum)) + { + return LicenseType.Platinum; + } + + if (reader.ValueTextEquals(MemberMissing)) + { + return LicenseType.Missing; + } + + if (reader.ValueTextEquals(MemberGold)) + { + return LicenseType.Gold; + } + + if (reader.ValueTextEquals(MemberEnterprise)) + { + return LicenseType.Enterprise; + } + + if (reader.ValueTextEquals(MemberDev)) + { + return LicenseType.Dev; + } + + if (reader.ValueTextEquals(MemberBasic)) + { + return LicenseType.Basic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LicenseType)}'."); } - public override void Write(Utf8JsonWriter writer, LicenseType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LicenseType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LicenseType.Trial: - writer.WriteStringValue("trial"); - return; + writer.WriteStringValue(MemberTrial); + break; case LicenseType.Standard: - writer.WriteStringValue("standard"); - return; + writer.WriteStringValue(MemberStandard); + break; case LicenseType.Silver: - writer.WriteStringValue("silver"); - return; + writer.WriteStringValue(MemberSilver); + break; case LicenseType.Platinum: - writer.WriteStringValue("platinum"); - return; + writer.WriteStringValue(MemberPlatinum); + break; case LicenseType.Missing: - writer.WriteStringValue("missing"); - return; + writer.WriteStringValue(MemberMissing); + break; case LicenseType.Gold: - writer.WriteStringValue("gold"); - return; + writer.WriteStringValue(MemberGold); + break; case LicenseType.Enterprise: - writer.WriteStringValue("enterprise"); - return; + writer.WriteStringValue(MemberEnterprise); + break; case LicenseType.Dev: - writer.WriteStringValue("dev"); - return; + writer.WriteStringValue(MemberDev); + break; case LicenseType.Basic: - writer.WriteStringValue("basic"); - return; + writer.WriteStringValue(MemberBasic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LicenseType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.MachineLearning.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.MachineLearning.g.cs index 31515f05fd6..d6d15e1eca9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.MachineLearning.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.MachineLearning.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum AppliesTo Actual } -internal sealed class AppliesToConverter : JsonConverter +internal sealed partial class AppliesToConverter : System.Text.Json.Serialization.JsonConverter { - public override AppliesTo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTypical = System.Text.Json.JsonEncodedText.Encode("typical"); + private static readonly System.Text.Json.JsonEncodedText MemberTime = System.Text.Json.JsonEncodedText.Encode("time"); + private static readonly System.Text.Json.JsonEncodedText MemberDiffFromTypical = System.Text.Json.JsonEncodedText.Encode("diff_from_typical"); + private static readonly System.Text.Json.JsonEncodedText MemberActual = System.Text.Json.JsonEncodedText.Encode("actual"); + + public override AppliesTo Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTypical)) + { + return AppliesTo.Typical; + } + + if (reader.ValueTextEquals(MemberTime)) + { + return AppliesTo.Time; + } + + if (reader.ValueTextEquals(MemberDiffFromTypical)) { - case "typical": - return AppliesTo.Typical; - case "time": - return AppliesTo.Time; - case "diff_from_typical": - return AppliesTo.DiffFromTypical; - case "actual": - return AppliesTo.Actual; + return AppliesTo.DiffFromTypical; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberActual)) + { + return AppliesTo.Actual; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AppliesTo)}'."); } - public override void Write(Utf8JsonWriter writer, AppliesTo value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AppliesTo value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AppliesTo.Typical: - writer.WriteStringValue("typical"); - return; + writer.WriteStringValue(MemberTypical); + break; case AppliesTo.Time: - writer.WriteStringValue("time"); - return; + writer.WriteStringValue(MemberTime); + break; case AppliesTo.DiffFromTypical: - writer.WriteStringValue("diff_from_typical"); - return; + writer.WriteStringValue(MemberDiffFromTypical); + break; case AppliesTo.Actual: - writer.WriteStringValue("actual"); - return; + writer.WriteStringValue(MemberActual); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AppliesTo)}'."); } - - writer.WriteNullValue(); } } @@ -93,36 +106,40 @@ public enum CategorizationStatus Ok } -internal sealed class CategorizationStatusConverter : JsonConverter +internal sealed partial class CategorizationStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override CategorizationStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWarn = System.Text.Json.JsonEncodedText.Encode("warn"); + private static readonly System.Text.Json.JsonEncodedText MemberOk = System.Text.Json.JsonEncodedText.Encode("ok"); + + public override CategorizationStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWarn)) + { + return CategorizationStatus.Warn; + } + + if (reader.ValueTextEquals(MemberOk)) { - case "warn": - return CategorizationStatus.Warn; - case "ok": - return CategorizationStatus.Ok; + return CategorizationStatus.Ok; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CategorizationStatus)}'."); } - public override void Write(Utf8JsonWriter writer, CategorizationStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CategorizationStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CategorizationStatus.Warn: - writer.WriteStringValue("warn"); - return; + writer.WriteStringValue(MemberWarn); + break; case CategorizationStatus.Ok: - writer.WriteStringValue("ok"); - return; + writer.WriteStringValue(MemberOk); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CategorizationStatus)}'."); } - - writer.WriteNullValue(); } } @@ -137,41 +154,49 @@ public enum ChunkingMode Auto } -internal sealed class ChunkingModeConverter : JsonConverter +internal sealed partial class ChunkingModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ChunkingMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOff = System.Text.Json.JsonEncodedText.Encode("off"); + private static readonly System.Text.Json.JsonEncodedText MemberManual = System.Text.Json.JsonEncodedText.Encode("manual"); + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override ChunkingMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOff)) + { + return ChunkingMode.Off; + } + + if (reader.ValueTextEquals(MemberManual)) { - case "off": - return ChunkingMode.Off; - case "manual": - return ChunkingMode.Manual; - case "auto": - return ChunkingMode.Auto; + return ChunkingMode.Manual; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAuto)) + { + return ChunkingMode.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ChunkingMode)}'."); } - public override void Write(Utf8JsonWriter writer, ChunkingMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChunkingMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ChunkingMode.Off: - writer.WriteStringValue("off"); - return; + writer.WriteStringValue(MemberOff); + break; case ChunkingMode.Manual: - writer.WriteStringValue("manual"); - return; + writer.WriteStringValue(MemberManual); + break; case ChunkingMode.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ChunkingMode)}'."); } - - writer.WriteNullValue(); } } @@ -188,46 +213,58 @@ public enum ConditionOperator Gt } -internal sealed class ConditionOperatorConverter : JsonConverter +internal sealed partial class ConditionOperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override ConditionOperator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText MemberLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberGt = System.Text.Json.JsonEncodedText.Encode("gt"); + + public override ConditionOperator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLte)) { - case "lte": - return ConditionOperator.Lte; - case "lt": - return ConditionOperator.Lt; - case "gte": - return ConditionOperator.Gte; - case "gt": - return ConditionOperator.Gt; + return ConditionOperator.Lte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLt)) + { + return ConditionOperator.Lt; + } + + if (reader.ValueTextEquals(MemberGte)) + { + return ConditionOperator.Gte; + } + + if (reader.ValueTextEquals(MemberGt)) + { + return ConditionOperator.Gt; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ConditionOperator)}'."); } - public override void Write(Utf8JsonWriter writer, ConditionOperator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ConditionOperator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ConditionOperator.Lte: - writer.WriteStringValue("lte"); - return; + writer.WriteStringValue(MemberLte); + break; case ConditionOperator.Lt: - writer.WriteStringValue("lt"); - return; + writer.WriteStringValue(MemberLt); + break; case ConditionOperator.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case ConditionOperator.Gt: - writer.WriteStringValue("gt"); - return; + writer.WriteStringValue(MemberGt); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ConditionOperator)}'."); } - - writer.WriteNullValue(); } } @@ -244,46 +281,58 @@ public enum DatafeedState Started } -internal sealed class DatafeedStateConverter : JsonConverter +internal sealed partial class DatafeedStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DatafeedState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override DatafeedState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DatafeedState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) { - case "stopping": - return DatafeedState.Stopping; - case "stopped": - return DatafeedState.Stopped; - case "starting": - return DatafeedState.Starting; - case "started": - return DatafeedState.Started; + return DatafeedState.Stopped; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStarting)) + { + return DatafeedState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DatafeedState.Started; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DatafeedState)}'."); } - public override void Write(Utf8JsonWriter writer, DatafeedState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatafeedState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DatafeedState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DatafeedState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case DatafeedState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DatafeedState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DatafeedState)}'."); } - - writer.WriteNullValue(); } } @@ -302,51 +351,67 @@ public enum DataframeState Failed } -internal sealed class DataframeStateConverter : JsonConverter +internal sealed partial class DataframeStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override DataframeState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "stopping": - return DataframeState.Stopping; - case "stopped": - return DataframeState.Stopped; - case "starting": - return DataframeState.Starting; - case "started": - return DataframeState.Started; - case "failed": - return DataframeState.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DataframeState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return DataframeState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DataframeState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DataframeState.Started; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return DataframeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DataframeState)}'."); } - public override void Write(Utf8JsonWriter writer, DataframeState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DataframeState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DataframeState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case DataframeState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DataframeState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DataframeState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DataframeState)}'."); } - - writer.WriteNullValue(); } } @@ -376,41 +441,49 @@ public enum DeploymentAllocationState FullyAllocated } -internal sealed class DeploymentAllocationStateConverter : JsonConverter +internal sealed partial class DeploymentAllocationStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DeploymentAllocationState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFullyAllocated = System.Text.Json.JsonEncodedText.Encode("fully_allocated"); + + public override DeploymentAllocationState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStarting)) { - case "starting": - return DeploymentAllocationState.Starting; - case "started": - return DeploymentAllocationState.Started; - case "fully_allocated": - return DeploymentAllocationState.FullyAllocated; + return DeploymentAllocationState.Starting; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStarted)) + { + return DeploymentAllocationState.Started; + } + + if (reader.ValueTextEquals(MemberFullyAllocated)) + { + return DeploymentAllocationState.FullyAllocated; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DeploymentAllocationState)}'."); } - public override void Write(Utf8JsonWriter writer, DeploymentAllocationState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeploymentAllocationState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DeploymentAllocationState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DeploymentAllocationState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DeploymentAllocationState.FullyAllocated: - writer.WriteStringValue("fully_allocated"); - return; + writer.WriteStringValue(MemberFullyAllocated); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DeploymentAllocationState)}'."); } - - writer.WriteNullValue(); } } @@ -447,46 +520,58 @@ public enum DeploymentAssignmentState Failed } -internal sealed class DeploymentAssignmentStateConverter : JsonConverter +internal sealed partial class DeploymentAssignmentStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DeploymentAssignmentState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override DeploymentAssignmentState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DeploymentAssignmentState.Stopping; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DeploymentAssignmentState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) { - case "stopping": - return DeploymentAssignmentState.Stopping; - case "starting": - return DeploymentAssignmentState.Starting; - case "started": - return DeploymentAssignmentState.Started; - case "failed": - return DeploymentAssignmentState.Failed; + return DeploymentAssignmentState.Started; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFailed)) + { + return DeploymentAssignmentState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DeploymentAssignmentState)}'."); } - public override void Write(Utf8JsonWriter writer, DeploymentAssignmentState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeploymentAssignmentState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DeploymentAssignmentState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DeploymentAssignmentState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DeploymentAssignmentState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DeploymentAssignmentState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DeploymentAssignmentState)}'."); } - - writer.WriteNullValue(); } } @@ -503,46 +588,58 @@ public enum ExcludeFrequent All } -internal sealed class ExcludeFrequentConverter : JsonConverter +internal sealed partial class ExcludeFrequentConverter : System.Text.Json.Serialization.JsonConverter { - public override ExcludeFrequent Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOver = System.Text.Json.JsonEncodedText.Encode("over"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberBy = System.Text.Json.JsonEncodedText.Encode("by"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ExcludeFrequent Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOver)) + { + return ExcludeFrequent.Over; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ExcludeFrequent.None; + } + + if (reader.ValueTextEquals(MemberBy)) { - case "over": - return ExcludeFrequent.Over; - case "none": - return ExcludeFrequent.None; - case "by": - return ExcludeFrequent.By; - case "all": - return ExcludeFrequent.All; + return ExcludeFrequent.By; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAll)) + { + return ExcludeFrequent.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ExcludeFrequent)}'."); } - public override void Write(Utf8JsonWriter writer, ExcludeFrequent value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExcludeFrequent value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ExcludeFrequent.Over: - writer.WriteStringValue("over"); - return; + writer.WriteStringValue(MemberOver); + break; case ExcludeFrequent.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ExcludeFrequent.By: - writer.WriteStringValue("by"); - return; + writer.WriteStringValue(MemberBy); + break; case ExcludeFrequent.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ExcludeFrequent)}'."); } - - writer.WriteNullValue(); } } @@ -555,36 +652,40 @@ public enum FilterType Exclude } -internal sealed class FilterTypeConverter : JsonConverter +internal sealed partial class FilterTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FilterType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override FilterType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInclude)) + { + return FilterType.Include; + } + + if (reader.ValueTextEquals(MemberExclude)) { - case "include": - return FilterType.Include; - case "exclude": - return FilterType.Exclude; + return FilterType.Exclude; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FilterType)}'."); } - public override void Write(Utf8JsonWriter writer, FilterType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FilterType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FilterType.Include: - writer.WriteStringValue("include"); - return; + writer.WriteStringValue(MemberInclude); + break; case FilterType.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FilterType)}'."); } - - writer.WriteNullValue(); } } @@ -633,51 +734,67 @@ public enum Include Definition } -internal sealed class IncludeConverter : JsonConverter +internal sealed partial class IncludeConverter : System.Text.Json.Serialization.JsonConverter { - public override Include Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTotalFeatureImportance = System.Text.Json.JsonEncodedText.Encode("total_feature_importance"); + private static readonly System.Text.Json.JsonEncodedText MemberHyperparameters = System.Text.Json.JsonEncodedText.Encode("hyperparameters"); + private static readonly System.Text.Json.JsonEncodedText MemberFeatureImportanceBaseline = System.Text.Json.JsonEncodedText.Encode("feature_importance_baseline"); + private static readonly System.Text.Json.JsonEncodedText MemberDefinitionStatus = System.Text.Json.JsonEncodedText.Encode("definition_status"); + private static readonly System.Text.Json.JsonEncodedText MemberDefinition = System.Text.Json.JsonEncodedText.Encode("definition"); + + public override Include Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "total_feature_importance": - return Include.TotalFeatureImportance; - case "hyperparameters": - return Include.Hyperparameters; - case "feature_importance_baseline": - return Include.FeatureImportanceBaseline; - case "definition_status": - return Include.DefinitionStatus; - case "definition": - return Include.Definition; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTotalFeatureImportance)) + { + return Include.TotalFeatureImportance; + } + + if (reader.ValueTextEquals(MemberHyperparameters)) + { + return Include.Hyperparameters; + } + + if (reader.ValueTextEquals(MemberFeatureImportanceBaseline)) + { + return Include.FeatureImportanceBaseline; + } + + if (reader.ValueTextEquals(MemberDefinitionStatus)) + { + return Include.DefinitionStatus; + } + + if (reader.ValueTextEquals(MemberDefinition)) + { + return Include.Definition; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Include)}'."); } - public override void Write(Utf8JsonWriter writer, Include value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Include value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Include.TotalFeatureImportance: - writer.WriteStringValue("total_feature_importance"); - return; + writer.WriteStringValue(MemberTotalFeatureImportance); + break; case Include.Hyperparameters: - writer.WriteStringValue("hyperparameters"); - return; + writer.WriteStringValue(MemberHyperparameters); + break; case Include.FeatureImportanceBaseline: - writer.WriteStringValue("feature_importance_baseline"); - return; + writer.WriteStringValue(MemberFeatureImportanceBaseline); + break; case Include.DefinitionStatus: - writer.WriteStringValue("definition_status"); - return; + writer.WriteStringValue(MemberDefinitionStatus); + break; case Include.Definition: - writer.WriteStringValue("definition"); - return; + writer.WriteStringValue(MemberDefinition); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Include)}'."); } - - writer.WriteNullValue(); } } @@ -692,41 +809,49 @@ public enum JobBlockedReason Delete } -internal sealed class JobBlockedReasonConverter : JsonConverter +internal sealed partial class JobBlockedReasonConverter : System.Text.Json.Serialization.JsonConverter { - public override JobBlockedReason Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRevert = System.Text.Json.JsonEncodedText.Encode("revert"); + private static readonly System.Text.Json.JsonEncodedText MemberReset = System.Text.Json.JsonEncodedText.Encode("reset"); + private static readonly System.Text.Json.JsonEncodedText MemberDelete = System.Text.Json.JsonEncodedText.Encode("delete"); + + public override JobBlockedReason Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRevert)) { - case "revert": - return JobBlockedReason.Revert; - case "reset": - return JobBlockedReason.Reset; - case "delete": - return JobBlockedReason.Delete; + return JobBlockedReason.Revert; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberReset)) + { + return JobBlockedReason.Reset; + } + + if (reader.ValueTextEquals(MemberDelete)) + { + return JobBlockedReason.Delete; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JobBlockedReason)}'."); } - public override void Write(Utf8JsonWriter writer, JobBlockedReason value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JobBlockedReason value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JobBlockedReason.Revert: - writer.WriteStringValue("revert"); - return; + writer.WriteStringValue(MemberRevert); + break; case JobBlockedReason.Reset: - writer.WriteStringValue("reset"); - return; + writer.WriteStringValue(MemberReset); + break; case JobBlockedReason.Delete: - writer.WriteStringValue("delete"); - return; + writer.WriteStringValue(MemberDelete); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JobBlockedReason)}'."); } - - writer.WriteNullValue(); } } @@ -773,51 +898,67 @@ public enum JobState Closed } -internal sealed class JobStateConverter : JsonConverter +internal sealed partial class JobStateConverter : System.Text.Json.Serialization.JsonConverter { - public override JobState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpening = System.Text.Json.JsonEncodedText.Encode("opening"); + private static readonly System.Text.Json.JsonEncodedText MemberOpened = System.Text.Json.JsonEncodedText.Encode("opened"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + private static readonly System.Text.Json.JsonEncodedText MemberClosing = System.Text.Json.JsonEncodedText.Encode("closing"); + private static readonly System.Text.Json.JsonEncodedText MemberClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + + public override JobState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "opening": - return JobState.Opening; - case "opened": - return JobState.Opened; - case "failed": - return JobState.Failed; - case "closing": - return JobState.Closing; - case "closed": - return JobState.Closed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpening)) + { + return JobState.Opening; + } + + if (reader.ValueTextEquals(MemberOpened)) + { + return JobState.Opened; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return JobState.Failed; + } + + if (reader.ValueTextEquals(MemberClosing)) + { + return JobState.Closing; + } + + if (reader.ValueTextEquals(MemberClosed)) + { + return JobState.Closed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JobState)}'."); } - public override void Write(Utf8JsonWriter writer, JobState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JobState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JobState.Opening: - writer.WriteStringValue("opening"); - return; + writer.WriteStringValue(MemberOpening); + break; case JobState.Opened: - writer.WriteStringValue("opened"); - return; + writer.WriteStringValue(MemberOpened); + break; case JobState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; case JobState.Closing: - writer.WriteStringValue("closing"); - return; + writer.WriteStringValue(MemberClosing); + break; case JobState.Closed: - writer.WriteStringValue("closed"); - return; + writer.WriteStringValue(MemberClosed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JobState)}'."); } - - writer.WriteNullValue(); } } @@ -832,41 +973,49 @@ public enum MemoryStatus HardLimit } -internal sealed class MemoryStatusConverter : JsonConverter +internal sealed partial class MemoryStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override MemoryStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSoftLimit = System.Text.Json.JsonEncodedText.Encode("soft_limit"); + private static readonly System.Text.Json.JsonEncodedText MemberOk = System.Text.Json.JsonEncodedText.Encode("ok"); + private static readonly System.Text.Json.JsonEncodedText MemberHardLimit = System.Text.Json.JsonEncodedText.Encode("hard_limit"); + + public override MemoryStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSoftLimit)) + { + return MemoryStatus.SoftLimit; + } + + if (reader.ValueTextEquals(MemberOk)) + { + return MemoryStatus.Ok; + } + + if (reader.ValueTextEquals(MemberHardLimit)) { - case "soft_limit": - return MemoryStatus.SoftLimit; - case "ok": - return MemoryStatus.Ok; - case "hard_limit": - return MemoryStatus.HardLimit; + return MemoryStatus.HardLimit; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MemoryStatus)}'."); } - public override void Write(Utf8JsonWriter writer, MemoryStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MemoryStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MemoryStatus.SoftLimit: - writer.WriteStringValue("soft_limit"); - return; + writer.WriteStringValue(MemberSoftLimit); + break; case MemoryStatus.Ok: - writer.WriteStringValue("ok"); - return; + writer.WriteStringValue(MemberOk); + break; case MemoryStatus.HardLimit: - writer.WriteStringValue("hard_limit"); - return; + writer.WriteStringValue(MemberHardLimit); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MemoryStatus)}'."); } - - writer.WriteNullValue(); } } @@ -910,51 +1059,67 @@ public enum RoutingState Failed } -internal sealed class RoutingStateConverter : JsonConverter +internal sealed partial class RoutingStateConverter : System.Text.Json.Serialization.JsonConverter { - public override RoutingState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override RoutingState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "stopping": - return RoutingState.Stopping; - case "stopped": - return RoutingState.Stopped; - case "starting": - return RoutingState.Starting; - case "started": - return RoutingState.Started; - case "failed": - return RoutingState.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return RoutingState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return RoutingState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return RoutingState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return RoutingState.Started; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return RoutingState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RoutingState)}'."); } - public override void Write(Utf8JsonWriter writer, RoutingState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RoutingState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RoutingState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case RoutingState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case RoutingState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case RoutingState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case RoutingState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RoutingState)}'."); } - - writer.WriteNullValue(); } } @@ -977,36 +1142,40 @@ public enum RuleAction SkipModelUpdate } -internal sealed class RuleActionConverter : JsonConverter +internal sealed partial class RuleActionConverter : System.Text.Json.Serialization.JsonConverter { - public override RuleAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSkipResult = System.Text.Json.JsonEncodedText.Encode("skip_result"); + private static readonly System.Text.Json.JsonEncodedText MemberSkipModelUpdate = System.Text.Json.JsonEncodedText.Encode("skip_model_update"); + + public override RuleAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSkipResult)) + { + return RuleAction.SkipResult; + } + + if (reader.ValueTextEquals(MemberSkipModelUpdate)) { - case "skip_result": - return RuleAction.SkipResult; - case "skip_model_update": - return RuleAction.SkipModelUpdate; + return RuleAction.SkipModelUpdate; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RuleAction)}'."); } - public override void Write(Utf8JsonWriter writer, RuleAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuleAction value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RuleAction.SkipResult: - writer.WriteStringValue("skip_result"); - return; + writer.WriteStringValue(MemberSkipResult); + break; case RuleAction.SkipModelUpdate: - writer.WriteStringValue("skip_model_update"); - return; + writer.WriteStringValue(MemberSkipModelUpdate); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RuleAction)}'."); } - - writer.WriteNullValue(); } } @@ -1023,46 +1192,58 @@ public enum SnapshotUpgradeState Failed } -internal sealed class SnapshotUpgradeStateConverter : JsonConverter +internal sealed partial class SnapshotUpgradeStateConverter : System.Text.Json.Serialization.JsonConverter { - public override SnapshotUpgradeState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberSavingNewState = System.Text.Json.JsonEncodedText.Encode("saving_new_state"); + private static readonly System.Text.Json.JsonEncodedText MemberLoadingOldState = System.Text.Json.JsonEncodedText.Encode("loading_old_state"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override SnapshotUpgradeState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopped)) + { + return SnapshotUpgradeState.Stopped; + } + + if (reader.ValueTextEquals(MemberSavingNewState)) + { + return SnapshotUpgradeState.SavingNewState; + } + + if (reader.ValueTextEquals(MemberLoadingOldState)) { - case "stopped": - return SnapshotUpgradeState.Stopped; - case "saving_new_state": - return SnapshotUpgradeState.SavingNewState; - case "loading_old_state": - return SnapshotUpgradeState.LoadingOldState; - case "failed": - return SnapshotUpgradeState.Failed; + return SnapshotUpgradeState.LoadingOldState; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFailed)) + { + return SnapshotUpgradeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnapshotUpgradeState)}'."); } - public override void Write(Utf8JsonWriter writer, SnapshotUpgradeState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotUpgradeState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnapshotUpgradeState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case SnapshotUpgradeState.SavingNewState: - writer.WriteStringValue("saving_new_state"); - return; + writer.WriteStringValue(MemberSavingNewState); + break; case SnapshotUpgradeState.LoadingOldState: - writer.WriteStringValue("loading_old_state"); - return; + writer.WriteStringValue(MemberLoadingOldState); + break; case SnapshotUpgradeState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnapshotUpgradeState)}'."); } - - writer.WriteNullValue(); } } @@ -1077,41 +1258,49 @@ public enum TokenizationTruncate First } -internal sealed class TokenizationTruncateConverter : JsonConverter +internal sealed partial class TokenizationTruncateConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenizationTruncate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + + public override TokenizationTruncate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSecond)) { - case "second": - return TokenizationTruncate.Second; - case "none": - return TokenizationTruncate.None; - case "first": - return TokenizationTruncate.First; + return TokenizationTruncate.Second; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNone)) + { + return TokenizationTruncate.None; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return TokenizationTruncate.First; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TokenizationTruncate)}'."); } - public override void Write(Utf8JsonWriter writer, TokenizationTruncate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenizationTruncate value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TokenizationTruncate.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case TokenizationTruncate.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case TokenizationTruncate.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TokenizationTruncate)}'."); } - - writer.WriteNullValue(); } } @@ -1142,41 +1331,49 @@ public enum TrainedModelType LangIdent } -internal sealed class TrainedModelTypeConverter : JsonConverter +internal sealed partial class TrainedModelTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TrainedModelType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTreeEnsemble = System.Text.Json.JsonEncodedText.Encode("tree_ensemble"); + private static readonly System.Text.Json.JsonEncodedText MemberPytorch = System.Text.Json.JsonEncodedText.Encode("pytorch"); + private static readonly System.Text.Json.JsonEncodedText MemberLangIdent = System.Text.Json.JsonEncodedText.Encode("lang_ident"); + + public override TrainedModelType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTreeEnsemble)) { - case "tree_ensemble": - return TrainedModelType.TreeEnsemble; - case "pytorch": - return TrainedModelType.Pytorch; - case "lang_ident": - return TrainedModelType.LangIdent; + return TrainedModelType.TreeEnsemble; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberPytorch)) + { + return TrainedModelType.Pytorch; + } + + if (reader.ValueTextEquals(MemberLangIdent)) + { + return TrainedModelType.LangIdent; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TrainedModelType)}'."); } - public override void Write(Utf8JsonWriter writer, TrainedModelType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TrainedModelType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TrainedModelType.TreeEnsemble: - writer.WriteStringValue("tree_ensemble"); - return; + writer.WriteStringValue(MemberTreeEnsemble); + break; case TrainedModelType.Pytorch: - writer.WriteStringValue("pytorch"); - return; + writer.WriteStringValue(MemberPytorch); + break; case TrainedModelType.LangIdent: - writer.WriteStringValue("lang_ident"); - return; + writer.WriteStringValue(MemberLangIdent); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TrainedModelType)}'."); } - - writer.WriteNullValue(); } } @@ -1189,35 +1386,39 @@ public enum TrainingPriority Low } -internal sealed class TrainingPriorityConverter : JsonConverter +internal sealed partial class TrainingPriorityConverter : System.Text.Json.Serialization.JsonConverter { - public override TrainingPriority Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberLow = System.Text.Json.JsonEncodedText.Encode("low"); + + public override TrainingPriority Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNormal)) + { + return TrainingPriority.Normal; + } + + if (reader.ValueTextEquals(MemberLow)) { - case "normal": - return TrainingPriority.Normal; - case "low": - return TrainingPriority.Low; + return TrainingPriority.Low; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TrainingPriority)}'."); } - public override void Write(Utf8JsonWriter writer, TrainingPriority value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TrainingPriority value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TrainingPriority.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case TrainingPriority.Low: - writer.WriteStringValue("low"); - return; + writer.WriteStringValue(MemberLow); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TrainingPriority)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Mapping.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Mapping.g.cs index 35464a20739..1686b54f0fe 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Mapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Mapping.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -58,41 +59,49 @@ public enum DenseVectorElementType Bit } -internal sealed class DenseVectorElementTypeConverter : JsonConverter +internal sealed partial class DenseVectorElementTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorElementType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberByte = System.Text.Json.JsonEncodedText.Encode("byte"); + private static readonly System.Text.Json.JsonEncodedText MemberBit = System.Text.Json.JsonEncodedText.Encode("bit"); + + public override DenseVectorElementType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFloat)) + { + return DenseVectorElementType.Float; + } + + if (reader.ValueTextEquals(MemberByte)) + { + return DenseVectorElementType.Byte; + } + + if (reader.ValueTextEquals(MemberBit)) { - case "float": - return DenseVectorElementType.Float; - case "byte": - return DenseVectorElementType.Byte; - case "bit": - return DenseVectorElementType.Bit; + return DenseVectorElementType.Bit; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorElementType)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorElementType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorElementType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorElementType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case DenseVectorElementType.Byte: - writer.WriteStringValue("byte"); - return; + writer.WriteStringValue(MemberByte); + break; case DenseVectorElementType.Bit: - writer.WriteStringValue("bit"); - return; + writer.WriteStringValue(MemberBit); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorElementType)}'."); } - - writer.WriteNullValue(); } } @@ -153,56 +162,76 @@ public enum DenseVectorIndexOptionsType Flat } -internal sealed class DenseVectorIndexOptionsTypeConverter : JsonConverter +internal sealed partial class DenseVectorIndexOptionsTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorIndexOptionsType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInt8Hnsw = System.Text.Json.JsonEncodedText.Encode("int8_hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberInt8Flat = System.Text.Json.JsonEncodedText.Encode("int8_flat"); + private static readonly System.Text.Json.JsonEncodedText MemberInt4Hnsw = System.Text.Json.JsonEncodedText.Encode("int4_hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberInt4Flat = System.Text.Json.JsonEncodedText.Encode("int4_flat"); + private static readonly System.Text.Json.JsonEncodedText MemberHnsw = System.Text.Json.JsonEncodedText.Encode("hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberFlat = System.Text.Json.JsonEncodedText.Encode("flat"); + + public override DenseVectorIndexOptionsType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "int8_hnsw": - return DenseVectorIndexOptionsType.Int8Hnsw; - case "int8_flat": - return DenseVectorIndexOptionsType.Int8Flat; - case "int4_hnsw": - return DenseVectorIndexOptionsType.Int4Hnsw; - case "int4_flat": - return DenseVectorIndexOptionsType.Int4Flat; - case "hnsw": - return DenseVectorIndexOptionsType.Hnsw; - case "flat": - return DenseVectorIndexOptionsType.Flat; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInt8Hnsw)) + { + return DenseVectorIndexOptionsType.Int8Hnsw; + } + + if (reader.ValueTextEquals(MemberInt8Flat)) + { + return DenseVectorIndexOptionsType.Int8Flat; + } + + if (reader.ValueTextEquals(MemberInt4Hnsw)) + { + return DenseVectorIndexOptionsType.Int4Hnsw; + } + + if (reader.ValueTextEquals(MemberInt4Flat)) + { + return DenseVectorIndexOptionsType.Int4Flat; + } + + if (reader.ValueTextEquals(MemberHnsw)) + { + return DenseVectorIndexOptionsType.Hnsw; + } + + if (reader.ValueTextEquals(MemberFlat)) + { + return DenseVectorIndexOptionsType.Flat; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorIndexOptionsType)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorIndexOptionsType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorIndexOptionsType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorIndexOptionsType.Int8Hnsw: - writer.WriteStringValue("int8_hnsw"); - return; + writer.WriteStringValue(MemberInt8Hnsw); + break; case DenseVectorIndexOptionsType.Int8Flat: - writer.WriteStringValue("int8_flat"); - return; + writer.WriteStringValue(MemberInt8Flat); + break; case DenseVectorIndexOptionsType.Int4Hnsw: - writer.WriteStringValue("int4_hnsw"); - return; + writer.WriteStringValue(MemberInt4Hnsw); + break; case DenseVectorIndexOptionsType.Int4Flat: - writer.WriteStringValue("int4_flat"); - return; + writer.WriteStringValue(MemberInt4Flat); + break; case DenseVectorIndexOptionsType.Hnsw: - writer.WriteStringValue("hnsw"); - return; + writer.WriteStringValue(MemberHnsw); + break; case DenseVectorIndexOptionsType.Flat: - writer.WriteStringValue("flat"); - return; + writer.WriteStringValue(MemberFlat); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorIndexOptionsType)}'."); } - - writer.WriteNullValue(); } } @@ -277,46 +306,58 @@ public enum DenseVectorSimilarity Cosine } -internal sealed class DenseVectorSimilarityConverter : JsonConverter +internal sealed partial class DenseVectorSimilarityConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorSimilarity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMaxInnerProduct = System.Text.Json.JsonEncodedText.Encode("max_inner_product"); + private static readonly System.Text.Json.JsonEncodedText MemberL2Norm = System.Text.Json.JsonEncodedText.Encode("l2_norm"); + private static readonly System.Text.Json.JsonEncodedText MemberDotProduct = System.Text.Json.JsonEncodedText.Encode("dot_product"); + private static readonly System.Text.Json.JsonEncodedText MemberCosine = System.Text.Json.JsonEncodedText.Encode("cosine"); + + public override DenseVectorSimilarity Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMaxInnerProduct)) { - case "max_inner_product": - return DenseVectorSimilarity.MaxInnerProduct; - case "l2_norm": - return DenseVectorSimilarity.L2Norm; - case "dot_product": - return DenseVectorSimilarity.DotProduct; - case "cosine": - return DenseVectorSimilarity.Cosine; + return DenseVectorSimilarity.MaxInnerProduct; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberL2Norm)) + { + return DenseVectorSimilarity.L2Norm; + } + + if (reader.ValueTextEquals(MemberDotProduct)) + { + return DenseVectorSimilarity.DotProduct; + } + + if (reader.ValueTextEquals(MemberCosine)) + { + return DenseVectorSimilarity.Cosine; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorSimilarity)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorSimilarity value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorSimilarity value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorSimilarity.MaxInnerProduct: - writer.WriteStringValue("max_inner_product"); - return; + writer.WriteStringValue(MemberMaxInnerProduct); + break; case DenseVectorSimilarity.L2Norm: - writer.WriteStringValue("l2_norm"); - return; + writer.WriteStringValue(MemberL2Norm); + break; case DenseVectorSimilarity.DotProduct: - writer.WriteStringValue("dot_product"); - return; + writer.WriteStringValue(MemberDotProduct); + break; case DenseVectorSimilarity.Cosine: - writer.WriteStringValue("cosine"); - return; + writer.WriteStringValue(MemberCosine); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorSimilarity)}'."); } - - writer.WriteNullValue(); } } @@ -333,46 +374,58 @@ public enum DynamicMapping False } -internal sealed class DynamicMappingConverter : JsonConverter +internal sealed partial class DynamicMappingConverter : System.Text.Json.Serialization.JsonConverter { - public override DynamicMapping Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrue = System.Text.Json.JsonEncodedText.Encode("true"); + private static readonly System.Text.Json.JsonEncodedText MemberStrict = System.Text.Json.JsonEncodedText.Encode("strict"); + private static readonly System.Text.Json.JsonEncodedText MemberRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + private static readonly System.Text.Json.JsonEncodedText MemberFalse = System.Text.Json.JsonEncodedText.Encode("false"); + + public override DynamicMapping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrue)) + { + return DynamicMapping.True; + } + + if (reader.ValueTextEquals(MemberStrict)) + { + return DynamicMapping.Strict; + } + + if (reader.ValueTextEquals(MemberRuntime)) + { + return DynamicMapping.Runtime; + } + + if (reader.ValueTextEquals(MemberFalse)) { - case "true": - return DynamicMapping.True; - case "strict": - return DynamicMapping.Strict; - case "runtime": - return DynamicMapping.Runtime; - case "false": - return DynamicMapping.False; + return DynamicMapping.False; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DynamicMapping)}'."); } - public override void Write(Utf8JsonWriter writer, DynamicMapping value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicMapping value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DynamicMapping.True: - writer.WriteStringValue("true"); - return; + writer.WriteStringValue(MemberTrue); + break; case DynamicMapping.Strict: - writer.WriteStringValue("strict"); - return; + writer.WriteStringValue(MemberStrict); + break; case DynamicMapping.Runtime: - writer.WriteStringValue("runtime"); - return; + writer.WriteStringValue(MemberRuntime); + break; case DynamicMapping.False: - writer.WriteStringValue("false"); - return; + writer.WriteStringValue(MemberFalse); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DynamicMapping)}'."); } - - writer.WriteNullValue(); } } @@ -475,261 +528,445 @@ public enum FieldType AggregateMetricDouble } -internal sealed class FieldTypeConverter : JsonConverter +internal sealed partial class FieldTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberTokenCount = System.Text.Json.JsonEncodedText.Encode("token_count"); + private static readonly System.Text.Json.JsonEncodedText MemberText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText MemberSparseVector = System.Text.Json.JsonEncodedText.Encode("sparse_vector"); + private static readonly System.Text.Json.JsonEncodedText MemberShort = System.Text.Json.JsonEncodedText.Encode("short"); + private static readonly System.Text.Json.JsonEncodedText MemberShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText MemberSemanticText = System.Text.Json.JsonEncodedText.Encode("semantic_text"); + private static readonly System.Text.Json.JsonEncodedText MemberSearchAsYouType = System.Text.Json.JsonEncodedText.Encode("search_as_you_type"); + private static readonly System.Text.Json.JsonEncodedText MemberScaledFloat = System.Text.Json.JsonEncodedText.Encode("scaled_float"); + private static readonly System.Text.Json.JsonEncodedText MemberRankFeatures = System.Text.Json.JsonEncodedText.Encode("rank_features"); + private static readonly System.Text.Json.JsonEncodedText MemberRankFeature = System.Text.Json.JsonEncodedText.Encode("rank_feature"); + private static readonly System.Text.Json.JsonEncodedText MemberPercolator = System.Text.Json.JsonEncodedText.Encode("percolator"); + private static readonly System.Text.Json.JsonEncodedText MemberPassthrough = System.Text.Json.JsonEncodedText.Encode("passthrough"); + private static readonly System.Text.Json.JsonEncodedText MemberObject = System.Text.Json.JsonEncodedText.Encode("object"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText MemberMurmur3 = System.Text.Json.JsonEncodedText.Encode("murmur3"); + private static readonly System.Text.Json.JsonEncodedText MemberMatchOnlyText = System.Text.Json.JsonEncodedText.Encode("match_only_text"); + private static readonly System.Text.Json.JsonEncodedText MemberLongRange = System.Text.Json.JsonEncodedText.Encode("long_range"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberJoin = System.Text.Json.JsonEncodedText.Encode("join"); + private static readonly System.Text.Json.JsonEncodedText MemberIpRange = System.Text.Json.JsonEncodedText.Encode("ip_range"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberIntegerRange = System.Text.Json.JsonEncodedText.Encode("integer_range"); + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("integer"); + private static readonly System.Text.Json.JsonEncodedText MemberIcuCollationKeyword = System.Text.Json.JsonEncodedText.Encode("icu_collation_keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText MemberHalfFloat = System.Text.Json.JsonEncodedText.Encode("half_float"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberFloatRange = System.Text.Json.JsonEncodedText.Encode("float_range"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberFlattened = System.Text.Json.JsonEncodedText.Encode("flattened"); + private static readonly System.Text.Json.JsonEncodedText MemberDoubleRange = System.Text.Json.JsonEncodedText.Encode("double_range"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDenseVector = System.Text.Json.JsonEncodedText.Encode("dense_vector"); + private static readonly System.Text.Json.JsonEncodedText MemberDateRange = System.Text.Json.JsonEncodedText.Encode("date_range"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberConstantKeyword = System.Text.Json.JsonEncodedText.Encode("constant_keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + private static readonly System.Text.Json.JsonEncodedText MemberByte = System.Text.Json.JsonEncodedText.Encode("byte"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + private static readonly System.Text.Json.JsonEncodedText MemberBinary = System.Text.Json.JsonEncodedText.Encode("binary"); + private static readonly System.Text.Json.JsonEncodedText MemberAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText MemberAggregateMetricDouble = System.Text.Json.JsonEncodedText.Encode("aggregate_metric_double"); + + public override FieldType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "version": - return FieldType.Version; - case "token_count": - return FieldType.TokenCount; - case "text": - return FieldType.Text; - case "sparse_vector": - return FieldType.SparseVector; - case "short": - return FieldType.Short; - case "shape": - return FieldType.Shape; - case "semantic_text": - return FieldType.SemanticText; - case "search_as_you_type": - return FieldType.SearchAsYouType; - case "scaled_float": - return FieldType.ScaledFloat; - case "rank_features": - return FieldType.RankFeatures; - case "rank_feature": - return FieldType.RankFeature; - case "percolator": - return FieldType.Percolator; - case "passthrough": - return FieldType.Passthrough; - case "object": - return FieldType.Object; - case "none": - return FieldType.None; - case "nested": - return FieldType.Nested; - case "murmur3": - return FieldType.Murmur3; - case "match_only_text": - return FieldType.MatchOnlyText; - case "long_range": - return FieldType.LongRange; - case "long": - return FieldType.Long; - case "keyword": - return FieldType.Keyword; - case "join": - return FieldType.Join; - case "ip_range": - return FieldType.IpRange; - case "ip": - return FieldType.Ip; - case "integer_range": - return FieldType.IntegerRange; - case "integer": - return FieldType.Integer; - case "icu_collation_keyword": - return FieldType.IcuCollationKeyword; - case "histogram": - return FieldType.Histogram; - case "half_float": - return FieldType.HalfFloat; - case "geo_shape": - return FieldType.GeoShape; - case "geo_point": - return FieldType.GeoPoint; - case "float_range": - return FieldType.FloatRange; - case "float": - return FieldType.Float; - case "flattened": - return FieldType.Flattened; - case "double_range": - return FieldType.DoubleRange; - case "double": - return FieldType.Double; - case "dense_vector": - return FieldType.DenseVector; - case "date_range": - return FieldType.DateRange; - case "date_nanos": - return FieldType.DateNanos; - case "date": - return FieldType.Date; - case "constant_keyword": - return FieldType.ConstantKeyword; - case "completion": - return FieldType.Completion; - case "byte": - return FieldType.Byte; - case "boolean": - return FieldType.Boolean; - case "binary": - return FieldType.Binary; - case "alias": - return FieldType.Alias; - case "aggregate_metric_double": - return FieldType.AggregateMetricDouble; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return FieldType.Version; + } + + if (reader.ValueTextEquals(MemberTokenCount)) + { + return FieldType.TokenCount; + } + + if (reader.ValueTextEquals(MemberText)) + { + return FieldType.Text; + } + + if (reader.ValueTextEquals(MemberSparseVector)) + { + return FieldType.SparseVector; + } + + if (reader.ValueTextEquals(MemberShort)) + { + return FieldType.Short; + } + + if (reader.ValueTextEquals(MemberShape)) + { + return FieldType.Shape; + } + + if (reader.ValueTextEquals(MemberSemanticText)) + { + return FieldType.SemanticText; + } + + if (reader.ValueTextEquals(MemberSearchAsYouType)) + { + return FieldType.SearchAsYouType; + } + + if (reader.ValueTextEquals(MemberScaledFloat)) + { + return FieldType.ScaledFloat; + } + + if (reader.ValueTextEquals(MemberRankFeatures)) + { + return FieldType.RankFeatures; + } + + if (reader.ValueTextEquals(MemberRankFeature)) + { + return FieldType.RankFeature; + } + + if (reader.ValueTextEquals(MemberPercolator)) + { + return FieldType.Percolator; + } + + if (reader.ValueTextEquals(MemberPassthrough)) + { + return FieldType.Passthrough; + } + + if (reader.ValueTextEquals(MemberObject)) + { + return FieldType.Object; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return FieldType.None; + } + + if (reader.ValueTextEquals(MemberNested)) + { + return FieldType.Nested; + } + + if (reader.ValueTextEquals(MemberMurmur3)) + { + return FieldType.Murmur3; + } + + if (reader.ValueTextEquals(MemberMatchOnlyText)) + { + return FieldType.MatchOnlyText; + } + + if (reader.ValueTextEquals(MemberLongRange)) + { + return FieldType.LongRange; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return FieldType.Long; + } + + if (reader.ValueTextEquals(MemberKeyword)) + { + return FieldType.Keyword; + } + + if (reader.ValueTextEquals(MemberJoin)) + { + return FieldType.Join; + } + + if (reader.ValueTextEquals(MemberIpRange)) + { + return FieldType.IpRange; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return FieldType.Ip; + } + + if (reader.ValueTextEquals(MemberIntegerRange)) + { + return FieldType.IntegerRange; + } + + if (reader.ValueTextEquals(MemberInteger)) + { + return FieldType.Integer; + } + + if (reader.ValueTextEquals(MemberIcuCollationKeyword)) + { + return FieldType.IcuCollationKeyword; + } + + if (reader.ValueTextEquals(MemberHistogram)) + { + return FieldType.Histogram; + } + + if (reader.ValueTextEquals(MemberHalfFloat)) + { + return FieldType.HalfFloat; + } + + if (reader.ValueTextEquals(MemberGeoShape)) + { + return FieldType.GeoShape; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return FieldType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberFloatRange)) + { + return FieldType.FloatRange; + } + + if (reader.ValueTextEquals(MemberFloat)) + { + return FieldType.Float; + } + + if (reader.ValueTextEquals(MemberFlattened)) + { + return FieldType.Flattened; + } + + if (reader.ValueTextEquals(MemberDoubleRange)) + { + return FieldType.DoubleRange; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return FieldType.Double; + } + + if (reader.ValueTextEquals(MemberDenseVector)) + { + return FieldType.DenseVector; + } + + if (reader.ValueTextEquals(MemberDateRange)) + { + return FieldType.DateRange; + } + + if (reader.ValueTextEquals(MemberDateNanos)) + { + return FieldType.DateNanos; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return FieldType.Date; + } + + if (reader.ValueTextEquals(MemberConstantKeyword)) + { + return FieldType.ConstantKeyword; + } + + if (reader.ValueTextEquals(MemberCompletion)) + { + return FieldType.Completion; + } + + if (reader.ValueTextEquals(MemberByte)) + { + return FieldType.Byte; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return FieldType.Boolean; + } + + if (reader.ValueTextEquals(MemberBinary)) + { + return FieldType.Binary; + } + + if (reader.ValueTextEquals(MemberAlias)) + { + return FieldType.Alias; + } + + if (reader.ValueTextEquals(MemberAggregateMetricDouble)) + { + return FieldType.AggregateMetricDouble; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldType)}'."); } - public override void Write(Utf8JsonWriter writer, FieldType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldType.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case FieldType.TokenCount: - writer.WriteStringValue("token_count"); - return; + writer.WriteStringValue(MemberTokenCount); + break; case FieldType.Text: - writer.WriteStringValue("text"); - return; + writer.WriteStringValue(MemberText); + break; case FieldType.SparseVector: - writer.WriteStringValue("sparse_vector"); - return; + writer.WriteStringValue(MemberSparseVector); + break; case FieldType.Short: - writer.WriteStringValue("short"); - return; + writer.WriteStringValue(MemberShort); + break; case FieldType.Shape: - writer.WriteStringValue("shape"); - return; + writer.WriteStringValue(MemberShape); + break; case FieldType.SemanticText: - writer.WriteStringValue("semantic_text"); - return; + writer.WriteStringValue(MemberSemanticText); + break; case FieldType.SearchAsYouType: - writer.WriteStringValue("search_as_you_type"); - return; + writer.WriteStringValue(MemberSearchAsYouType); + break; case FieldType.ScaledFloat: - writer.WriteStringValue("scaled_float"); - return; + writer.WriteStringValue(MemberScaledFloat); + break; case FieldType.RankFeatures: - writer.WriteStringValue("rank_features"); - return; + writer.WriteStringValue(MemberRankFeatures); + break; case FieldType.RankFeature: - writer.WriteStringValue("rank_feature"); - return; + writer.WriteStringValue(MemberRankFeature); + break; case FieldType.Percolator: - writer.WriteStringValue("percolator"); - return; + writer.WriteStringValue(MemberPercolator); + break; case FieldType.Passthrough: - writer.WriteStringValue("passthrough"); - return; + writer.WriteStringValue(MemberPassthrough); + break; case FieldType.Object: - writer.WriteStringValue("object"); - return; + writer.WriteStringValue(MemberObject); + break; case FieldType.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case FieldType.Nested: - writer.WriteStringValue("nested"); - return; + writer.WriteStringValue(MemberNested); + break; case FieldType.Murmur3: - writer.WriteStringValue("murmur3"); - return; + writer.WriteStringValue(MemberMurmur3); + break; case FieldType.MatchOnlyText: - writer.WriteStringValue("match_only_text"); - return; + writer.WriteStringValue(MemberMatchOnlyText); + break; case FieldType.LongRange: - writer.WriteStringValue("long_range"); - return; + writer.WriteStringValue(MemberLongRange); + break; case FieldType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case FieldType.Keyword: - writer.WriteStringValue("keyword"); - return; + writer.WriteStringValue(MemberKeyword); + break; case FieldType.Join: - writer.WriteStringValue("join"); - return; + writer.WriteStringValue(MemberJoin); + break; case FieldType.IpRange: - writer.WriteStringValue("ip_range"); - return; + writer.WriteStringValue(MemberIpRange); + break; case FieldType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case FieldType.IntegerRange: - writer.WriteStringValue("integer_range"); - return; + writer.WriteStringValue(MemberIntegerRange); + break; case FieldType.Integer: - writer.WriteStringValue("integer"); - return; + writer.WriteStringValue(MemberInteger); + break; case FieldType.IcuCollationKeyword: - writer.WriteStringValue("icu_collation_keyword"); - return; + writer.WriteStringValue(MemberIcuCollationKeyword); + break; case FieldType.Histogram: - writer.WriteStringValue("histogram"); - return; + writer.WriteStringValue(MemberHistogram); + break; case FieldType.HalfFloat: - writer.WriteStringValue("half_float"); - return; + writer.WriteStringValue(MemberHalfFloat); + break; case FieldType.GeoShape: - writer.WriteStringValue("geo_shape"); - return; + writer.WriteStringValue(MemberGeoShape); + break; case FieldType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case FieldType.FloatRange: - writer.WriteStringValue("float_range"); - return; + writer.WriteStringValue(MemberFloatRange); + break; case FieldType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case FieldType.Flattened: - writer.WriteStringValue("flattened"); - return; + writer.WriteStringValue(MemberFlattened); + break; case FieldType.DoubleRange: - writer.WriteStringValue("double_range"); - return; + writer.WriteStringValue(MemberDoubleRange); + break; case FieldType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case FieldType.DenseVector: - writer.WriteStringValue("dense_vector"); - return; + writer.WriteStringValue(MemberDenseVector); + break; case FieldType.DateRange: - writer.WriteStringValue("date_range"); - return; + writer.WriteStringValue(MemberDateRange); + break; case FieldType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case FieldType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case FieldType.ConstantKeyword: - writer.WriteStringValue("constant_keyword"); - return; + writer.WriteStringValue(MemberConstantKeyword); + break; case FieldType.Completion: - writer.WriteStringValue("completion"); - return; + writer.WriteStringValue(MemberCompletion); + break; case FieldType.Byte: - writer.WriteStringValue("byte"); - return; + writer.WriteStringValue(MemberByte); + break; case FieldType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; case FieldType.Binary: - writer.WriteStringValue("binary"); - return; + writer.WriteStringValue(MemberBinary); + break; case FieldType.Alias: - writer.WriteStringValue("alias"); - return; + writer.WriteStringValue(MemberAlias); + break; case FieldType.AggregateMetricDouble: - writer.WriteStringValue("aggregate_metric_double"); - return; + writer.WriteStringValue(MemberAggregateMetricDouble); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldType)}'."); } - - writer.WriteNullValue(); } } @@ -742,42 +979,46 @@ public enum GeoOrientation Left } -internal sealed class GeoOrientationConverter : JsonConverter +internal sealed partial class GeoOrientationConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoOrientation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRight = System.Text.Json.JsonEncodedText.Encode("right"); + private static readonly System.Text.Json.JsonEncodedText MemberRight1 = System.Text.Json.JsonEncodedText.Encode("RIGHT"); + private static readonly System.Text.Json.JsonEncodedText MemberRight2 = System.Text.Json.JsonEncodedText.Encode("counterclockwise"); + private static readonly System.Text.Json.JsonEncodedText MemberRight3 = System.Text.Json.JsonEncodedText.Encode("ccw"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft = System.Text.Json.JsonEncodedText.Encode("left"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft1 = System.Text.Json.JsonEncodedText.Encode("LEFT"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft2 = System.Text.Json.JsonEncodedText.Encode("clockwise"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft3 = System.Text.Json.JsonEncodedText.Encode("cw"); + + public override GeoOrientation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "right": - case "RIGHT": - case "counterclockwise": - case "ccw": - return GeoOrientation.Right; - case "left": - case "LEFT": - case "clockwise": - case "cw": - return GeoOrientation.Left; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRight) || reader.ValueTextEquals(MemberRight1) || reader.ValueTextEquals(MemberRight2) || reader.ValueTextEquals(MemberRight3)) + { + return GeoOrientation.Right; + } + + if (reader.ValueTextEquals(MemberLeft) || reader.ValueTextEquals(MemberLeft1) || reader.ValueTextEquals(MemberLeft2) || reader.ValueTextEquals(MemberLeft3)) + { + return GeoOrientation.Left; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoOrientation)}'."); } - public override void Write(Utf8JsonWriter writer, GeoOrientation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoOrientation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoOrientation.Right: - writer.WriteStringValue("right"); - return; + writer.WriteStringValue(MemberRight); + break; case GeoOrientation.Left: - writer.WriteStringValue("left"); - return; + writer.WriteStringValue(MemberLeft); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoOrientation)}'."); } - - writer.WriteNullValue(); } } @@ -790,36 +1031,40 @@ public enum GeoStrategy Recursive } -internal sealed class GeoStrategyConverter : JsonConverter +internal sealed partial class GeoStrategyConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoStrategy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTerm = System.Text.Json.JsonEncodedText.Encode("term"); + private static readonly System.Text.Json.JsonEncodedText MemberRecursive = System.Text.Json.JsonEncodedText.Encode("recursive"); + + public override GeoStrategy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTerm)) { - case "term": - return GeoStrategy.Term; - case "recursive": - return GeoStrategy.Recursive; + return GeoStrategy.Term; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRecursive)) + { + return GeoStrategy.Recursive; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoStrategy)}'."); } - public override void Write(Utf8JsonWriter writer, GeoStrategy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoStrategy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoStrategy.Term: - writer.WriteStringValue("term"); - return; + writer.WriteStringValue(MemberTerm); + break; case GeoStrategy.Recursive: - writer.WriteStringValue("recursive"); - return; + writer.WriteStringValue(MemberRecursive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoStrategy)}'."); } - - writer.WriteNullValue(); } } @@ -836,46 +1081,58 @@ public enum IndexOptions Docs } -internal sealed class IndexOptionsConverter : JsonConverter +internal sealed partial class IndexOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPositions = System.Text.Json.JsonEncodedText.Encode("positions"); + private static readonly System.Text.Json.JsonEncodedText MemberOffsets = System.Text.Json.JsonEncodedText.Encode("offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberFreqs = System.Text.Json.JsonEncodedText.Encode("freqs"); + private static readonly System.Text.Json.JsonEncodedText MemberDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override IndexOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPositions)) + { + return IndexOptions.Positions; + } + + if (reader.ValueTextEquals(MemberOffsets)) { - case "positions": - return IndexOptions.Positions; - case "offsets": - return IndexOptions.Offsets; - case "freqs": - return IndexOptions.Freqs; - case "docs": - return IndexOptions.Docs; + return IndexOptions.Offsets; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFreqs)) + { + return IndexOptions.Freqs; + } + + if (reader.ValueTextEquals(MemberDocs)) + { + return IndexOptions.Docs; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexOptions.Positions: - writer.WriteStringValue("positions"); - return; + writer.WriteStringValue(MemberPositions); + break; case IndexOptions.Offsets: - writer.WriteStringValue("offsets"); - return; + writer.WriteStringValue(MemberOffsets); + break; case IndexOptions.Freqs: - writer.WriteStringValue("freqs"); - return; + writer.WriteStringValue(MemberFreqs); + break; case IndexOptions.Docs: - writer.WriteStringValue("docs"); - return; + writer.WriteStringValue(MemberDocs); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexOptions)}'."); } - - writer.WriteNullValue(); } } @@ -888,36 +1145,40 @@ public enum MatchType Regex } -internal sealed class MatchTypeConverter : JsonConverter +internal sealed partial class MatchTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSimple = System.Text.Json.JsonEncodedText.Encode("simple"); + private static readonly System.Text.Json.JsonEncodedText MemberRegex = System.Text.Json.JsonEncodedText.Encode("regex"); + + public override MatchType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSimple)) + { + return MatchType.Simple; + } + + if (reader.ValueTextEquals(MemberRegex)) { - case "simple": - return MatchType.Simple; - case "regex": - return MatchType.Regex; + return MatchType.Regex; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MatchType)}'."); } - public override void Write(Utf8JsonWriter writer, MatchType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MatchType.Simple: - writer.WriteStringValue("simple"); - return; + writer.WriteStringValue(MemberSimple); + break; case MatchType.Regex: - writer.WriteStringValue("regex"); - return; + writer.WriteStringValue(MemberRegex); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MatchType)}'."); } - - writer.WriteNullValue(); } } @@ -930,36 +1191,40 @@ public enum OnScriptError Continue } -internal sealed class OnScriptErrorConverter : JsonConverter +internal sealed partial class OnScriptErrorConverter : System.Text.Json.Serialization.JsonConverter { - public override OnScriptError Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFail = System.Text.Json.JsonEncodedText.Encode("fail"); + private static readonly System.Text.Json.JsonEncodedText MemberContinue = System.Text.Json.JsonEncodedText.Encode("continue"); + + public override OnScriptError Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFail)) { - case "fail": - return OnScriptError.Fail; - case "continue": - return OnScriptError.Continue; + return OnScriptError.Fail; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberContinue)) + { + return OnScriptError.Continue; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(OnScriptError)}'."); } - public override void Write(Utf8JsonWriter writer, OnScriptError value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, OnScriptError value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case OnScriptError.Fail: - writer.WriteStringValue("fail"); - return; + writer.WriteStringValue(MemberFail); + break; case OnScriptError.Continue: - writer.WriteStringValue("continue"); - return; + writer.WriteStringValue(MemberContinue); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(OnScriptError)}'."); } - - writer.WriteNullValue(); } } @@ -986,71 +1251,103 @@ public enum RuntimeFieldType Boolean } -internal sealed class RuntimeFieldTypeConverter : JsonConverter +internal sealed partial class RuntimeFieldTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override RuntimeFieldType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLookup = System.Text.Json.JsonEncodedText.Encode("lookup"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberComposite = System.Text.Json.JsonEncodedText.Encode("composite"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + + public override RuntimeFieldType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "lookup": - return RuntimeFieldType.Lookup; - case "long": - return RuntimeFieldType.Long; - case "keyword": - return RuntimeFieldType.Keyword; - case "ip": - return RuntimeFieldType.Ip; - case "geo_point": - return RuntimeFieldType.GeoPoint; - case "double": - return RuntimeFieldType.Double; - case "date": - return RuntimeFieldType.Date; - case "composite": - return RuntimeFieldType.Composite; - case "boolean": - return RuntimeFieldType.Boolean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLookup)) + { + return RuntimeFieldType.Lookup; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return RuntimeFieldType.Long; + } + + if (reader.ValueTextEquals(MemberKeyword)) + { + return RuntimeFieldType.Keyword; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return RuntimeFieldType.Ip; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return RuntimeFieldType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return RuntimeFieldType.Double; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return RuntimeFieldType.Date; + } + + if (reader.ValueTextEquals(MemberComposite)) + { + return RuntimeFieldType.Composite; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return RuntimeFieldType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RuntimeFieldType)}'."); } - public override void Write(Utf8JsonWriter writer, RuntimeFieldType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuntimeFieldType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RuntimeFieldType.Lookup: - writer.WriteStringValue("lookup"); - return; + writer.WriteStringValue(MemberLookup); + break; case RuntimeFieldType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case RuntimeFieldType.Keyword: - writer.WriteStringValue("keyword"); - return; + writer.WriteStringValue(MemberKeyword); + break; case RuntimeFieldType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case RuntimeFieldType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case RuntimeFieldType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case RuntimeFieldType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case RuntimeFieldType.Composite: - writer.WriteStringValue("composite"); - return; + writer.WriteStringValue(MemberComposite); + break; case RuntimeFieldType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RuntimeFieldType)}'."); } - - writer.WriteNullValue(); } } @@ -1071,41 +1368,49 @@ public enum SourceFieldMode Disabled } -internal sealed class SourceFieldModeConverter : JsonConverter +internal sealed partial class SourceFieldModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SourceFieldMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSynthetic = System.Text.Json.JsonEncodedText.Encode("synthetic"); + private static readonly System.Text.Json.JsonEncodedText MemberStored = System.Text.Json.JsonEncodedText.Encode("stored"); + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + + public override SourceFieldMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSynthetic)) { - case "synthetic": - return SourceFieldMode.Synthetic; - case "stored": - return SourceFieldMode.Stored; - case "disabled": - return SourceFieldMode.Disabled; + return SourceFieldMode.Synthetic; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStored)) + { + return SourceFieldMode.Stored; + } + + if (reader.ValueTextEquals(MemberDisabled)) + { + return SourceFieldMode.Disabled; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SourceFieldMode)}'."); } - public override void Write(Utf8JsonWriter writer, SourceFieldMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceFieldMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SourceFieldMode.Synthetic: - writer.WriteStringValue("synthetic"); - return; + writer.WriteStringValue(MemberSynthetic); + break; case SourceFieldMode.Stored: - writer.WriteStringValue("stored"); - return; + writer.WriteStringValue(MemberStored); + break; case SourceFieldMode.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SourceFieldMode)}'."); } - - writer.WriteNullValue(); } } @@ -1128,61 +1433,85 @@ public enum TermVectorOption No } -internal sealed class TermVectorOptionConverter : JsonConverter +internal sealed partial class TermVectorOptionConverter : System.Text.Json.Serialization.JsonConverter { - public override TermVectorOption Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("yes"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsPayloads = System.Text.Json.JsonEncodedText.Encode("with_positions_payloads"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsOffsetsPayloads = System.Text.Json.JsonEncodedText.Encode("with_positions_offsets_payloads"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsOffsets = System.Text.Json.JsonEncodedText.Encode("with_positions_offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositions = System.Text.Json.JsonEncodedText.Encode("with_positions"); + private static readonly System.Text.Json.JsonEncodedText MemberWithOffsets = System.Text.Json.JsonEncodedText.Encode("with_offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + + public override TermVectorOption Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yes": - return TermVectorOption.Yes; - case "with_positions_payloads": - return TermVectorOption.WithPositionsPayloads; - case "with_positions_offsets_payloads": - return TermVectorOption.WithPositionsOffsetsPayloads; - case "with_positions_offsets": - return TermVectorOption.WithPositionsOffsets; - case "with_positions": - return TermVectorOption.WithPositions; - case "with_offsets": - return TermVectorOption.WithOffsets; - case "no": - return TermVectorOption.No; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return TermVectorOption.Yes; + } + + if (reader.ValueTextEquals(MemberWithPositionsPayloads)) + { + return TermVectorOption.WithPositionsPayloads; + } + + if (reader.ValueTextEquals(MemberWithPositionsOffsetsPayloads)) + { + return TermVectorOption.WithPositionsOffsetsPayloads; + } + + if (reader.ValueTextEquals(MemberWithPositionsOffsets)) + { + return TermVectorOption.WithPositionsOffsets; + } + + if (reader.ValueTextEquals(MemberWithPositions)) + { + return TermVectorOption.WithPositions; + } + + if (reader.ValueTextEquals(MemberWithOffsets)) + { + return TermVectorOption.WithOffsets; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return TermVectorOption.No; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermVectorOption)}'."); } - public override void Write(Utf8JsonWriter writer, TermVectorOption value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorOption value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermVectorOption.Yes: - writer.WriteStringValue("yes"); - return; + writer.WriteStringValue(MemberYes); + break; case TermVectorOption.WithPositionsPayloads: - writer.WriteStringValue("with_positions_payloads"); - return; + writer.WriteStringValue(MemberWithPositionsPayloads); + break; case TermVectorOption.WithPositionsOffsetsPayloads: - writer.WriteStringValue("with_positions_offsets_payloads"); - return; + writer.WriteStringValue(MemberWithPositionsOffsetsPayloads); + break; case TermVectorOption.WithPositionsOffsets: - writer.WriteStringValue("with_positions_offsets"); - return; + writer.WriteStringValue(MemberWithPositionsOffsets); + break; case TermVectorOption.WithPositions: - writer.WriteStringValue("with_positions"); - return; + writer.WriteStringValue(MemberWithPositions); + break; case TermVectorOption.WithOffsets: - writer.WriteStringValue("with_offsets"); - return; + writer.WriteStringValue(MemberWithOffsets); + break; case TermVectorOption.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermVectorOption)}'."); } - - writer.WriteNullValue(); } } @@ -1201,50 +1530,66 @@ public enum TimeSeriesMetricType Counter } -internal sealed class TimeSeriesMetricTypeConverter : JsonConverter +internal sealed partial class TimeSeriesMetricTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeSeriesMetricType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSummary = System.Text.Json.JsonEncodedText.Encode("summary"); + private static readonly System.Text.Json.JsonEncodedText MemberPosition = System.Text.Json.JsonEncodedText.Encode("position"); + private static readonly System.Text.Json.JsonEncodedText MemberHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText MemberGauge = System.Text.Json.JsonEncodedText.Encode("gauge"); + private static readonly System.Text.Json.JsonEncodedText MemberCounter = System.Text.Json.JsonEncodedText.Encode("counter"); + + public override TimeSeriesMetricType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "summary": - return TimeSeriesMetricType.Summary; - case "position": - return TimeSeriesMetricType.Position; - case "histogram": - return TimeSeriesMetricType.Histogram; - case "gauge": - return TimeSeriesMetricType.Gauge; - case "counter": - return TimeSeriesMetricType.Counter; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSummary)) + { + return TimeSeriesMetricType.Summary; + } + + if (reader.ValueTextEquals(MemberPosition)) + { + return TimeSeriesMetricType.Position; + } + + if (reader.ValueTextEquals(MemberHistogram)) + { + return TimeSeriesMetricType.Histogram; + } + + if (reader.ValueTextEquals(MemberGauge)) + { + return TimeSeriesMetricType.Gauge; + } + + if (reader.ValueTextEquals(MemberCounter)) + { + return TimeSeriesMetricType.Counter; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TimeSeriesMetricType)}'."); } - public override void Write(Utf8JsonWriter writer, TimeSeriesMetricType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeSeriesMetricType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TimeSeriesMetricType.Summary: - writer.WriteStringValue("summary"); - return; + writer.WriteStringValue(MemberSummary); + break; case TimeSeriesMetricType.Position: - writer.WriteStringValue("position"); - return; + writer.WriteStringValue(MemberPosition); + break; case TimeSeriesMetricType.Histogram: - writer.WriteStringValue("histogram"); - return; + writer.WriteStringValue(MemberHistogram); + break; case TimeSeriesMetricType.Gauge: - writer.WriteStringValue("gauge"); - return; + writer.WriteStringValue(MemberGauge); + break; case TimeSeriesMetricType.Counter: - writer.WriteStringValue("counter"); - return; + writer.WriteStringValue(MemberCounter); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TimeSeriesMetricType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.NoNamespace.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.NoNamespace.g.cs index d44b52c36e8..532bae42b35 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.NoNamespace.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.NoNamespace.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -43,51 +44,67 @@ public enum ClusterInfoTarget All } -internal sealed class ClusterInfoTargetConverter : JsonConverter +internal sealed partial class ClusterInfoTargetConverter : System.Text.Json.Serialization.JsonConverter { - public override ClusterInfoTarget Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + private static readonly System.Text.Json.JsonEncodedText MemberScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("_all"); + + public override ClusterInfoTarget Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "thread_pool": - return ClusterInfoTarget.ThreadPool; - case "script": - return ClusterInfoTarget.Script; - case "ingest": - return ClusterInfoTarget.Ingest; - case "http": - return ClusterInfoTarget.Http; - case "_all": - return ClusterInfoTarget.All; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberThreadPool)) + { + return ClusterInfoTarget.ThreadPool; + } + + if (reader.ValueTextEquals(MemberScript)) + { + return ClusterInfoTarget.Script; + } + + if (reader.ValueTextEquals(MemberIngest)) + { + return ClusterInfoTarget.Ingest; + } + + if (reader.ValueTextEquals(MemberHttp)) + { + return ClusterInfoTarget.Http; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ClusterInfoTarget.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ClusterInfoTarget)}'."); } - public override void Write(Utf8JsonWriter writer, ClusterInfoTarget value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterInfoTarget value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ClusterInfoTarget.ThreadPool: - writer.WriteStringValue("thread_pool"); - return; + writer.WriteStringValue(MemberThreadPool); + break; case ClusterInfoTarget.Script: - writer.WriteStringValue("script"); - return; + writer.WriteStringValue(MemberScript); + break; case ClusterInfoTarget.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case ClusterInfoTarget.Http: - writer.WriteStringValue("http"); - return; + writer.WriteStringValue(MemberHttp); + break; case ClusterInfoTarget.All: - writer.WriteStringValue("_all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ClusterInfoTarget)}'."); } - - writer.WriteNullValue(); } } @@ -106,51 +123,67 @@ public enum ClusterSearchStatus Failed } -internal sealed class ClusterSearchStatusConverter : JsonConverter +internal sealed partial class ClusterSearchStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override ClusterSearchStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSuccessful = System.Text.Json.JsonEncodedText.Encode("successful"); + private static readonly System.Text.Json.JsonEncodedText MemberSkipped = System.Text.Json.JsonEncodedText.Encode("skipped"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("running"); + private static readonly System.Text.Json.JsonEncodedText MemberPartial = System.Text.Json.JsonEncodedText.Encode("partial"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override ClusterSearchStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "successful": - return ClusterSearchStatus.Successful; - case "skipped": - return ClusterSearchStatus.Skipped; - case "running": - return ClusterSearchStatus.Running; - case "partial": - return ClusterSearchStatus.Partial; - case "failed": - return ClusterSearchStatus.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSuccessful)) + { + return ClusterSearchStatus.Successful; + } + + if (reader.ValueTextEquals(MemberSkipped)) + { + return ClusterSearchStatus.Skipped; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return ClusterSearchStatus.Running; + } + + if (reader.ValueTextEquals(MemberPartial)) + { + return ClusterSearchStatus.Partial; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return ClusterSearchStatus.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ClusterSearchStatus)}'."); } - public override void Write(Utf8JsonWriter writer, ClusterSearchStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterSearchStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ClusterSearchStatus.Successful: - writer.WriteStringValue("successful"); - return; + writer.WriteStringValue(MemberSuccessful); + break; case ClusterSearchStatus.Skipped: - writer.WriteStringValue("skipped"); - return; + writer.WriteStringValue(MemberSkipped); + break; case ClusterSearchStatus.Running: - writer.WriteStringValue("running"); - return; + writer.WriteStringValue(MemberRunning); + break; case ClusterSearchStatus.Partial: - writer.WriteStringValue("partial"); - return; + writer.WriteStringValue(MemberPartial); + break; case ClusterSearchStatus.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ClusterSearchStatus)}'."); } - - writer.WriteNullValue(); } } @@ -173,36 +206,40 @@ public enum Conflicts Abort } -internal sealed class ConflictsConverter : JsonConverter +internal sealed partial class ConflictsConverter : System.Text.Json.Serialization.JsonConverter { - public override Conflicts Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberProceed = System.Text.Json.JsonEncodedText.Encode("proceed"); + private static readonly System.Text.Json.JsonEncodedText MemberAbort = System.Text.Json.JsonEncodedText.Encode("abort"); + + public override Conflicts Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberProceed)) + { + return Conflicts.Proceed; + } + + if (reader.ValueTextEquals(MemberAbort)) { - case "proceed": - return Conflicts.Proceed; - case "abort": - return Conflicts.Abort; + return Conflicts.Abort; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Conflicts)}'."); } - public override void Write(Utf8JsonWriter writer, Conflicts value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Conflicts value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Conflicts.Proceed: - writer.WriteStringValue("proceed"); - return; + writer.WriteStringValue(MemberProceed); + break; case Conflicts.Abort: - writer.WriteStringValue("abort"); - return; + writer.WriteStringValue(MemberAbort); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Conflicts)}'."); } - - writer.WriteNullValue(); } } @@ -217,41 +254,49 @@ public enum DFIIndependenceMeasure Chisquared } -internal sealed class DFIIndependenceMeasureConverter : JsonConverter +internal sealed partial class DFIIndependenceMeasureConverter : System.Text.Json.Serialization.JsonConverter { - public override DFIIndependenceMeasure Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStandardized = System.Text.Json.JsonEncodedText.Encode("standardized"); + private static readonly System.Text.Json.JsonEncodedText MemberSaturated = System.Text.Json.JsonEncodedText.Encode("saturated"); + private static readonly System.Text.Json.JsonEncodedText MemberChisquared = System.Text.Json.JsonEncodedText.Encode("chisquared"); + + public override DFIIndependenceMeasure Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStandardized)) + { + return DFIIndependenceMeasure.Standardized; + } + + if (reader.ValueTextEquals(MemberSaturated)) + { + return DFIIndependenceMeasure.Saturated; + } + + if (reader.ValueTextEquals(MemberChisquared)) { - case "standardized": - return DFIIndependenceMeasure.Standardized; - case "saturated": - return DFIIndependenceMeasure.Saturated; - case "chisquared": - return DFIIndependenceMeasure.Chisquared; + return DFIIndependenceMeasure.Chisquared; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFIIndependenceMeasure)}'."); } - public override void Write(Utf8JsonWriter writer, DFIIndependenceMeasure value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFIIndependenceMeasure value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFIIndependenceMeasure.Standardized: - writer.WriteStringValue("standardized"); - return; + writer.WriteStringValue(MemberStandardized); + break; case DFIIndependenceMeasure.Saturated: - writer.WriteStringValue("saturated"); - return; + writer.WriteStringValue(MemberSaturated); + break; case DFIIndependenceMeasure.Chisquared: - writer.WriteStringValue("chisquared"); - return; + writer.WriteStringValue(MemberChisquared); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFIIndependenceMeasure)}'."); } - - writer.WriteNullValue(); } } @@ -266,41 +311,49 @@ public enum DFRAfterEffect b } -internal sealed class DFRAfterEffectConverter : JsonConverter +internal sealed partial class DFRAfterEffectConverter : System.Text.Json.Serialization.JsonConverter { - public override DFRAfterEffect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText Memberl = System.Text.Json.JsonEncodedText.Encode("l"); + private static readonly System.Text.Json.JsonEncodedText Memberb = System.Text.Json.JsonEncodedText.Encode("b"); + + public override DFRAfterEffect Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNo)) { - case "no": - return DFRAfterEffect.No; - case "l": - return DFRAfterEffect.l; - case "b": - return DFRAfterEffect.b; + return DFRAfterEffect.No; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(Memberl)) + { + return DFRAfterEffect.l; + } + + if (reader.ValueTextEquals(Memberb)) + { + return DFRAfterEffect.b; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFRAfterEffect)}'."); } - public override void Write(Utf8JsonWriter writer, DFRAfterEffect value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFRAfterEffect value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFRAfterEffect.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case DFRAfterEffect.l: - writer.WriteStringValue("l"); - return; + writer.WriteStringValue(Memberl); + break; case DFRAfterEffect.b: - writer.WriteStringValue("b"); - return; + writer.WriteStringValue(Memberb); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFRAfterEffect)}'."); } - - writer.WriteNullValue(); } } @@ -323,61 +376,85 @@ public enum DFRBasicModel Be } -internal sealed class DFRBasicModelConverter : JsonConverter +internal sealed partial class DFRBasicModelConverter : System.Text.Json.Serialization.JsonConverter { - public override DFRBasicModel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText Memberp = System.Text.Json.JsonEncodedText.Encode("p"); + private static readonly System.Text.Json.JsonEncodedText MemberIne = System.Text.Json.JsonEncodedText.Encode("ine"); + private static readonly System.Text.Json.JsonEncodedText MemberIn = System.Text.Json.JsonEncodedText.Encode("in"); + private static readonly System.Text.Json.JsonEncodedText MemberIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText Memberg = System.Text.Json.JsonEncodedText.Encode("g"); + private static readonly System.Text.Json.JsonEncodedText Memberd = System.Text.Json.JsonEncodedText.Encode("d"); + private static readonly System.Text.Json.JsonEncodedText MemberBe = System.Text.Json.JsonEncodedText.Encode("be"); + + public override DFRBasicModel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "p": - return DFRBasicModel.p; - case "ine": - return DFRBasicModel.Ine; - case "in": - return DFRBasicModel.In; - case "if": - return DFRBasicModel.If; - case "g": - return DFRBasicModel.g; - case "d": - return DFRBasicModel.d; - case "be": - return DFRBasicModel.Be; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(Memberp)) + { + return DFRBasicModel.p; + } + + if (reader.ValueTextEquals(MemberIne)) + { + return DFRBasicModel.Ine; + } + + if (reader.ValueTextEquals(MemberIn)) + { + return DFRBasicModel.In; + } + + if (reader.ValueTextEquals(MemberIf)) + { + return DFRBasicModel.If; + } + + if (reader.ValueTextEquals(Memberg)) + { + return DFRBasicModel.g; + } + + if (reader.ValueTextEquals(Memberd)) + { + return DFRBasicModel.d; + } + + if (reader.ValueTextEquals(MemberBe)) + { + return DFRBasicModel.Be; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFRBasicModel)}'."); } - public override void Write(Utf8JsonWriter writer, DFRBasicModel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFRBasicModel value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFRBasicModel.p: - writer.WriteStringValue("p"); - return; + writer.WriteStringValue(Memberp); + break; case DFRBasicModel.Ine: - writer.WriteStringValue("ine"); - return; + writer.WriteStringValue(MemberIne); + break; case DFRBasicModel.In: - writer.WriteStringValue("in"); - return; + writer.WriteStringValue(MemberIn); + break; case DFRBasicModel.If: - writer.WriteStringValue("if"); - return; + writer.WriteStringValue(MemberIf); + break; case DFRBasicModel.g: - writer.WriteStringValue("g"); - return; + writer.WriteStringValue(Memberg); + break; case DFRBasicModel.d: - writer.WriteStringValue("d"); - return; + writer.WriteStringValue(Memberd); + break; case DFRBasicModel.Be: - writer.WriteStringValue("be"); - return; + writer.WriteStringValue(MemberBe); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFRBasicModel)}'."); } - - writer.WriteNullValue(); } } @@ -404,71 +481,103 @@ public enum DistanceUnit Centimeters } -internal sealed class DistanceUnitConverter : JsonConverter +internal sealed partial class DistanceUnitConverter : System.Text.Json.Serialization.JsonConverter { - public override DistanceUnit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYards = System.Text.Json.JsonEncodedText.Encode("yd"); + private static readonly System.Text.Json.JsonEncodedText MemberNauticMiles = System.Text.Json.JsonEncodedText.Encode("nmi"); + private static readonly System.Text.Json.JsonEncodedText MemberMillimeters = System.Text.Json.JsonEncodedText.Encode("mm"); + private static readonly System.Text.Json.JsonEncodedText MemberMiles = System.Text.Json.JsonEncodedText.Encode("mi"); + private static readonly System.Text.Json.JsonEncodedText MemberMeters = System.Text.Json.JsonEncodedText.Encode("m"); + private static readonly System.Text.Json.JsonEncodedText MemberKilometers = System.Text.Json.JsonEncodedText.Encode("km"); + private static readonly System.Text.Json.JsonEncodedText MemberInches = System.Text.Json.JsonEncodedText.Encode("in"); + private static readonly System.Text.Json.JsonEncodedText MemberFeet = System.Text.Json.JsonEncodedText.Encode("ft"); + private static readonly System.Text.Json.JsonEncodedText MemberCentimeters = System.Text.Json.JsonEncodedText.Encode("cm"); + + public override DistanceUnit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yd": - return DistanceUnit.Yards; - case "nmi": - return DistanceUnit.NauticMiles; - case "mm": - return DistanceUnit.Millimeters; - case "mi": - return DistanceUnit.Miles; - case "m": - return DistanceUnit.Meters; - case "km": - return DistanceUnit.Kilometers; - case "in": - return DistanceUnit.Inches; - case "ft": - return DistanceUnit.Feet; - case "cm": - return DistanceUnit.Centimeters; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYards)) + { + return DistanceUnit.Yards; + } + + if (reader.ValueTextEquals(MemberNauticMiles)) + { + return DistanceUnit.NauticMiles; + } + + if (reader.ValueTextEquals(MemberMillimeters)) + { + return DistanceUnit.Millimeters; + } + + if (reader.ValueTextEquals(MemberMiles)) + { + return DistanceUnit.Miles; + } + + if (reader.ValueTextEquals(MemberMeters)) + { + return DistanceUnit.Meters; + } + + if (reader.ValueTextEquals(MemberKilometers)) + { + return DistanceUnit.Kilometers; + } + + if (reader.ValueTextEquals(MemberInches)) + { + return DistanceUnit.Inches; + } + + if (reader.ValueTextEquals(MemberFeet)) + { + return DistanceUnit.Feet; + } + + if (reader.ValueTextEquals(MemberCentimeters)) + { + return DistanceUnit.Centimeters; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DistanceUnit)}'."); } - public override void Write(Utf8JsonWriter writer, DistanceUnit value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DistanceUnit value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DistanceUnit.Yards: - writer.WriteStringValue("yd"); - return; + writer.WriteStringValue(MemberYards); + break; case DistanceUnit.NauticMiles: - writer.WriteStringValue("nmi"); - return; + writer.WriteStringValue(MemberNauticMiles); + break; case DistanceUnit.Millimeters: - writer.WriteStringValue("mm"); - return; + writer.WriteStringValue(MemberMillimeters); + break; case DistanceUnit.Miles: - writer.WriteStringValue("mi"); - return; + writer.WriteStringValue(MemberMiles); + break; case DistanceUnit.Meters: - writer.WriteStringValue("m"); - return; + writer.WriteStringValue(MemberMeters); + break; case DistanceUnit.Kilometers: - writer.WriteStringValue("km"); - return; + writer.WriteStringValue(MemberKilometers); + break; case DistanceUnit.Inches: - writer.WriteStringValue("in"); - return; + writer.WriteStringValue(MemberInches); + break; case DistanceUnit.Feet: - writer.WriteStringValue("ft"); - return; + writer.WriteStringValue(MemberFeet); + break; case DistanceUnit.Centimeters: - writer.WriteStringValue("cm"); - return; + writer.WriteStringValue(MemberCentimeters); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DistanceUnit)}'."); } - - writer.WriteNullValue(); } } @@ -512,51 +621,67 @@ public enum ExpandWildcard All } -internal sealed class ExpandWildcardConverter : JsonConverter +internal sealed partial class ExpandWildcardConverter : System.Text.Json.Serialization.JsonConverter { - public override ExpandWildcard Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpen = System.Text.Json.JsonEncodedText.Encode("open"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberHidden = System.Text.Json.JsonEncodedText.Encode("hidden"); + private static readonly System.Text.Json.JsonEncodedText MemberClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ExpandWildcard Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "open": - return ExpandWildcard.Open; - case "none": - return ExpandWildcard.None; - case "hidden": - return ExpandWildcard.Hidden; - case "closed": - return ExpandWildcard.Closed; - case "all": - return ExpandWildcard.All; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpen)) + { + return ExpandWildcard.Open; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ExpandWildcard.None; + } + + if (reader.ValueTextEquals(MemberHidden)) + { + return ExpandWildcard.Hidden; + } + + if (reader.ValueTextEquals(MemberClosed)) + { + return ExpandWildcard.Closed; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ExpandWildcard.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ExpandWildcard)}'."); } - public override void Write(Utf8JsonWriter writer, ExpandWildcard value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExpandWildcard value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ExpandWildcard.Open: - writer.WriteStringValue("open"); - return; + writer.WriteStringValue(MemberOpen); + break; case ExpandWildcard.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ExpandWildcard.Hidden: - writer.WriteStringValue("hidden"); - return; + writer.WriteStringValue(MemberHidden); + break; case ExpandWildcard.Closed: - writer.WriteStringValue("closed"); - return; + writer.WriteStringValue(MemberClosed); + break; case ExpandWildcard.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ExpandWildcard)}'."); } - - writer.WriteNullValue(); } } @@ -573,46 +698,58 @@ public enum FieldSortNumericType Date } -internal sealed class FieldSortNumericTypeConverter : JsonConverter +internal sealed partial class FieldSortNumericTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldSortNumericType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + + public override FieldSortNumericType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLong)) + { + return FieldSortNumericType.Long; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return FieldSortNumericType.Double; + } + + if (reader.ValueTextEquals(MemberDateNanos)) { - case "long": - return FieldSortNumericType.Long; - case "double": - return FieldSortNumericType.Double; - case "date_nanos": - return FieldSortNumericType.DateNanos; - case "date": - return FieldSortNumericType.Date; + return FieldSortNumericType.DateNanos; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDate)) + { + return FieldSortNumericType.Date; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldSortNumericType)}'."); } - public override void Write(Utf8JsonWriter writer, FieldSortNumericType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSortNumericType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldSortNumericType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case FieldSortNumericType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case FieldSortNumericType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case FieldSortNumericType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldSortNumericType)}'."); } - - writer.WriteNullValue(); } } @@ -635,36 +772,40 @@ public enum GeoDistanceType Arc } -internal sealed class GeoDistanceTypeConverter : JsonConverter +internal sealed partial class GeoDistanceTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPlane = System.Text.Json.JsonEncodedText.Encode("plane"); + private static readonly System.Text.Json.JsonEncodedText MemberArc = System.Text.Json.JsonEncodedText.Encode("arc"); + + public override GeoDistanceType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPlane)) + { + return GeoDistanceType.Plane; + } + + if (reader.ValueTextEquals(MemberArc)) { - case "plane": - return GeoDistanceType.Plane; - case "arc": - return GeoDistanceType.Arc; + return GeoDistanceType.Arc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoDistanceType)}'."); } - public override void Write(Utf8JsonWriter writer, GeoDistanceType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoDistanceType.Plane: - writer.WriteStringValue("plane"); - return; + writer.WriteStringValue(MemberPlane); + break; case GeoDistanceType.Arc: - writer.WriteStringValue("arc"); - return; + writer.WriteStringValue(MemberArc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoDistanceType)}'."); } - - writer.WriteNullValue(); } } @@ -702,46 +843,58 @@ public enum GeoShapeRelation Contains } -internal sealed class GeoShapeRelationConverter : JsonConverter +internal sealed partial class GeoShapeRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoShapeRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWithin = System.Text.Json.JsonEncodedText.Encode("within"); + private static readonly System.Text.Json.JsonEncodedText MemberIntersects = System.Text.Json.JsonEncodedText.Encode("intersects"); + private static readonly System.Text.Json.JsonEncodedText MemberDisjoint = System.Text.Json.JsonEncodedText.Encode("disjoint"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + + public override GeoShapeRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWithin)) + { + return GeoShapeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) { - case "within": - return GeoShapeRelation.Within; - case "intersects": - return GeoShapeRelation.Intersects; - case "disjoint": - return GeoShapeRelation.Disjoint; - case "contains": - return GeoShapeRelation.Contains; + return GeoShapeRelation.Intersects; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDisjoint)) + { + return GeoShapeRelation.Disjoint; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return GeoShapeRelation.Contains; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoShapeRelation)}'."); } - public override void Write(Utf8JsonWriter writer, GeoShapeRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoShapeRelation.Within: - writer.WriteStringValue("within"); - return; + writer.WriteStringValue(MemberWithin); + break; case GeoShapeRelation.Intersects: - writer.WriteStringValue("intersects"); - return; + writer.WriteStringValue(MemberIntersects); + break; case GeoShapeRelation.Disjoint: - writer.WriteStringValue("disjoint"); - return; + writer.WriteStringValue(MemberDisjoint); + break; case GeoShapeRelation.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoShapeRelation)}'."); } - - writer.WriteNullValue(); } } @@ -771,44 +924,52 @@ public enum HealthStatus Green } -internal sealed class HealthStatusConverter : JsonConverter +internal sealed partial class HealthStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override HealthStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYellow = System.Text.Json.JsonEncodedText.Encode("yellow"); + private static readonly System.Text.Json.JsonEncodedText MemberYellow1 = System.Text.Json.JsonEncodedText.Encode("YELLOW"); + private static readonly System.Text.Json.JsonEncodedText MemberRed = System.Text.Json.JsonEncodedText.Encode("red"); + private static readonly System.Text.Json.JsonEncodedText MemberRed1 = System.Text.Json.JsonEncodedText.Encode("RED"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen = System.Text.Json.JsonEncodedText.Encode("green"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen1 = System.Text.Json.JsonEncodedText.Encode("GREEN"); + + public override HealthStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yellow": - case "YELLOW": - return HealthStatus.Yellow; - case "red": - case "RED": - return HealthStatus.Red; - case "green": - case "GREEN": - return HealthStatus.Green; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYellow) || reader.ValueTextEquals(MemberYellow1)) + { + return HealthStatus.Yellow; + } + + if (reader.ValueTextEquals(MemberRed) || reader.ValueTextEquals(MemberRed1)) + { + return HealthStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen) || reader.ValueTextEquals(MemberGreen1)) + { + return HealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HealthStatus)}'."); } - public override void Write(Utf8JsonWriter writer, HealthStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HealthStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case HealthStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case HealthStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HealthStatus)}'."); } - - writer.WriteNullValue(); } } @@ -821,36 +982,40 @@ public enum IBDistribution Ll } -internal sealed class IBDistributionConverter : JsonConverter +internal sealed partial class IBDistributionConverter : System.Text.Json.Serialization.JsonConverter { - public override IBDistribution Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpl = System.Text.Json.JsonEncodedText.Encode("spl"); + private static readonly System.Text.Json.JsonEncodedText MemberLl = System.Text.Json.JsonEncodedText.Encode("ll"); + + public override IBDistribution Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpl)) { - case "spl": - return IBDistribution.Spl; - case "ll": - return IBDistribution.Ll; + return IBDistribution.Spl; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLl)) + { + return IBDistribution.Ll; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IBDistribution)}'."); } - public override void Write(Utf8JsonWriter writer, IBDistribution value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IBDistribution value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IBDistribution.Spl: - writer.WriteStringValue("spl"); - return; + writer.WriteStringValue(MemberSpl); + break; case IBDistribution.Ll: - writer.WriteStringValue("ll"); - return; + writer.WriteStringValue(MemberLl); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IBDistribution)}'."); } - - writer.WriteNullValue(); } } @@ -863,36 +1028,40 @@ public enum IBLambda Df } -internal sealed class IBLambdaConverter : JsonConverter +internal sealed partial class IBLambdaConverter : System.Text.Json.Serialization.JsonConverter { - public override IBLambda Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTtf = System.Text.Json.JsonEncodedText.Encode("ttf"); + private static readonly System.Text.Json.JsonEncodedText MemberDf = System.Text.Json.JsonEncodedText.Encode("df"); + + public override IBLambda Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTtf)) { - case "ttf": - return IBLambda.Ttf; - case "df": - return IBLambda.Df; + return IBLambda.Ttf; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDf)) + { + return IBLambda.Df; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IBLambda)}'."); } - public override void Write(Utf8JsonWriter writer, IBLambda value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IBLambda value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IBLambda.Ttf: - writer.WriteStringValue("ttf"); - return; + writer.WriteStringValue(MemberTtf); + break; case IBLambda.Df: - writer.WriteStringValue("df"); - return; + writer.WriteStringValue(MemberDf); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IBLambda)}'."); } - - writer.WriteNullValue(); } } @@ -907,41 +1076,49 @@ public enum Level Cluster } -internal sealed class LevelConverter : JsonConverter +internal sealed partial class LevelConverter : System.Text.Json.Serialization.JsonConverter { - public override Level Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShards = System.Text.Json.JsonEncodedText.Encode("shards"); + private static readonly System.Text.Json.JsonEncodedText MemberIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText MemberCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + + public override Level Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShards)) + { + return Level.Shards; + } + + if (reader.ValueTextEquals(MemberIndices)) + { + return Level.Indices; + } + + if (reader.ValueTextEquals(MemberCluster)) { - case "shards": - return Level.Shards; - case "indices": - return Level.Indices; - case "cluster": - return Level.Cluster; + return Level.Cluster; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Level)}'."); } - public override void Write(Utf8JsonWriter writer, Level value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Level value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Level.Shards: - writer.WriteStringValue("shards"); - return; + writer.WriteStringValue(MemberShards); + break; case Level.Indices: - writer.WriteStringValue("indices"); - return; + writer.WriteStringValue(MemberIndices); + break; case Level.Cluster: - writer.WriteStringValue("cluster"); - return; + writer.WriteStringValue(MemberCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Level)}'."); } - - writer.WriteNullValue(); } } @@ -956,41 +1133,49 @@ public enum LifecycleOperationMode Running } -internal sealed class LifecycleOperationModeConverter : JsonConverter +internal sealed partial class LifecycleOperationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override LifecycleOperationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("STOPPING"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("STOPPED"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("RUNNING"); + + public override LifecycleOperationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) { - case "STOPPING": - return LifecycleOperationMode.Stopping; - case "STOPPED": - return LifecycleOperationMode.Stopped; - case "RUNNING": - return LifecycleOperationMode.Running; + return LifecycleOperationMode.Stopping; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStopped)) + { + return LifecycleOperationMode.Stopped; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return LifecycleOperationMode.Running; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LifecycleOperationMode)}'."); } - public override void Write(Utf8JsonWriter writer, LifecycleOperationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LifecycleOperationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LifecycleOperationMode.Stopping: - writer.WriteStringValue("STOPPING"); - return; + writer.WriteStringValue(MemberStopping); + break; case LifecycleOperationMode.Stopped: - writer.WriteStringValue("STOPPED"); - return; + writer.WriteStringValue(MemberStopped); + break; case LifecycleOperationMode.Running: - writer.WriteStringValue("RUNNING"); - return; + writer.WriteStringValue(MemberRunning); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LifecycleOperationMode)}'."); } - - writer.WriteNullValue(); } } @@ -1027,96 +1212,148 @@ public enum NodeRole Client } -internal sealed class NodeRoleConverter : JsonConverter +internal sealed partial class NodeRoleConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeRole Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVotingOnly = System.Text.Json.JsonEncodedText.Encode("voting_only"); + private static readonly System.Text.Json.JsonEncodedText MemberTransform = System.Text.Json.JsonEncodedText.Encode("transform"); + private static readonly System.Text.Json.JsonEncodedText MemberRemoteClusterClient = System.Text.Json.JsonEncodedText.Encode("remote_cluster_client"); + private static readonly System.Text.Json.JsonEncodedText MemberMl = System.Text.Json.JsonEncodedText.Encode("ml"); + private static readonly System.Text.Json.JsonEncodedText MemberMaster = System.Text.Json.JsonEncodedText.Encode("master"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberDataWarm = System.Text.Json.JsonEncodedText.Encode("data_warm"); + private static readonly System.Text.Json.JsonEncodedText MemberDataHot = System.Text.Json.JsonEncodedText.Encode("data_hot"); + private static readonly System.Text.Json.JsonEncodedText MemberDataFrozen = System.Text.Json.JsonEncodedText.Encode("data_frozen"); + private static readonly System.Text.Json.JsonEncodedText MemberDataContent = System.Text.Json.JsonEncodedText.Encode("data_content"); + private static readonly System.Text.Json.JsonEncodedText MemberDataCold = System.Text.Json.JsonEncodedText.Encode("data_cold"); + private static readonly System.Text.Json.JsonEncodedText MemberData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText MemberCoordinatingOnly = System.Text.Json.JsonEncodedText.Encode("coordinating_only"); + private static readonly System.Text.Json.JsonEncodedText MemberClient = System.Text.Json.JsonEncodedText.Encode("client"); + + public override NodeRole Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "voting_only": - return NodeRole.VotingOnly; - case "transform": - return NodeRole.Transform; - case "remote_cluster_client": - return NodeRole.RemoteClusterClient; - case "ml": - return NodeRole.Ml; - case "master": - return NodeRole.Master; - case "ingest": - return NodeRole.Ingest; - case "data_warm": - return NodeRole.DataWarm; - case "data_hot": - return NodeRole.DataHot; - case "data_frozen": - return NodeRole.DataFrozen; - case "data_content": - return NodeRole.DataContent; - case "data_cold": - return NodeRole.DataCold; - case "data": - return NodeRole.Data; - case "coordinating_only": - return NodeRole.CoordinatingOnly; - case "client": - return NodeRole.Client; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVotingOnly)) + { + return NodeRole.VotingOnly; + } + + if (reader.ValueTextEquals(MemberTransform)) + { + return NodeRole.Transform; + } + + if (reader.ValueTextEquals(MemberRemoteClusterClient)) + { + return NodeRole.RemoteClusterClient; + } + + if (reader.ValueTextEquals(MemberMl)) + { + return NodeRole.Ml; + } + + if (reader.ValueTextEquals(MemberMaster)) + { + return NodeRole.Master; + } + + if (reader.ValueTextEquals(MemberIngest)) + { + return NodeRole.Ingest; + } + + if (reader.ValueTextEquals(MemberDataWarm)) + { + return NodeRole.DataWarm; + } + + if (reader.ValueTextEquals(MemberDataHot)) + { + return NodeRole.DataHot; + } + + if (reader.ValueTextEquals(MemberDataFrozen)) + { + return NodeRole.DataFrozen; + } + + if (reader.ValueTextEquals(MemberDataContent)) + { + return NodeRole.DataContent; + } + + if (reader.ValueTextEquals(MemberDataCold)) + { + return NodeRole.DataCold; + } + + if (reader.ValueTextEquals(MemberData)) + { + return NodeRole.Data; + } + + if (reader.ValueTextEquals(MemberCoordinatingOnly)) + { + return NodeRole.CoordinatingOnly; + } + + if (reader.ValueTextEquals(MemberClient)) + { + return NodeRole.Client; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NodeRole)}'."); } - public override void Write(Utf8JsonWriter writer, NodeRole value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeRole value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NodeRole.VotingOnly: - writer.WriteStringValue("voting_only"); - return; + writer.WriteStringValue(MemberVotingOnly); + break; case NodeRole.Transform: - writer.WriteStringValue("transform"); - return; + writer.WriteStringValue(MemberTransform); + break; case NodeRole.RemoteClusterClient: - writer.WriteStringValue("remote_cluster_client"); - return; + writer.WriteStringValue(MemberRemoteClusterClient); + break; case NodeRole.Ml: - writer.WriteStringValue("ml"); - return; + writer.WriteStringValue(MemberMl); + break; case NodeRole.Master: - writer.WriteStringValue("master"); - return; + writer.WriteStringValue(MemberMaster); + break; case NodeRole.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case NodeRole.DataWarm: - writer.WriteStringValue("data_warm"); - return; + writer.WriteStringValue(MemberDataWarm); + break; case NodeRole.DataHot: - writer.WriteStringValue("data_hot"); - return; + writer.WriteStringValue(MemberDataHot); + break; case NodeRole.DataFrozen: - writer.WriteStringValue("data_frozen"); - return; + writer.WriteStringValue(MemberDataFrozen); + break; case NodeRole.DataContent: - writer.WriteStringValue("data_content"); - return; + writer.WriteStringValue(MemberDataContent); + break; case NodeRole.DataCold: - writer.WriteStringValue("data_cold"); - return; + writer.WriteStringValue(MemberDataCold); + break; case NodeRole.Data: - writer.WriteStringValue("data"); - return; + writer.WriteStringValue(MemberData); + break; case NodeRole.CoordinatingOnly: - writer.WriteStringValue("coordinating_only"); - return; + writer.WriteStringValue(MemberCoordinatingOnly); + break; case NodeRole.Client: - writer.WriteStringValue("client"); - return; + writer.WriteStringValue(MemberClient); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NodeRole)}'."); } - - writer.WriteNullValue(); } } @@ -1135,51 +1372,67 @@ public enum Normalization H1 } -internal sealed class NormalizationConverter : JsonConverter +internal sealed partial class NormalizationConverter : System.Text.Json.Serialization.JsonConverter { - public override Normalization Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText Memberz = System.Text.Json.JsonEncodedText.Encode("z"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberH3 = System.Text.Json.JsonEncodedText.Encode("h3"); + private static readonly System.Text.Json.JsonEncodedText MemberH2 = System.Text.Json.JsonEncodedText.Encode("h2"); + private static readonly System.Text.Json.JsonEncodedText MemberH1 = System.Text.Json.JsonEncodedText.Encode("h1"); + + public override Normalization Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "z": - return Normalization.z; - case "no": - return Normalization.No; - case "h3": - return Normalization.H3; - case "h2": - return Normalization.H2; - case "h1": - return Normalization.H1; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(Memberz)) + { + return Normalization.z; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return Normalization.No; + } + + if (reader.ValueTextEquals(MemberH3)) + { + return Normalization.H3; + } + + if (reader.ValueTextEquals(MemberH2)) + { + return Normalization.H2; + } + + if (reader.ValueTextEquals(MemberH1)) + { + return Normalization.H1; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Normalization)}'."); } - public override void Write(Utf8JsonWriter writer, Normalization value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Normalization value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Normalization.z: - writer.WriteStringValue("z"); - return; + writer.WriteStringValue(Memberz); + break; case Normalization.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case Normalization.H3: - writer.WriteStringValue("h3"); - return; + writer.WriteStringValue(MemberH3); + break; case Normalization.H2: - writer.WriteStringValue("h2"); - return; + writer.WriteStringValue(MemberH2); + break; case Normalization.H1: - writer.WriteStringValue("h1"); - return; + writer.WriteStringValue(MemberH1); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Normalization)}'."); } - - writer.WriteNullValue(); } } @@ -1198,51 +1451,67 @@ public enum Result Created } -internal sealed class ResultConverter : JsonConverter +internal sealed partial class ResultConverter : System.Text.Json.Serialization.JsonConverter { - public override Result Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText MemberNotFound = System.Text.Json.JsonEncodedText.Encode("not_found"); + private static readonly System.Text.Json.JsonEncodedText MemberNoOp = System.Text.Json.JsonEncodedText.Encode("noop"); + private static readonly System.Text.Json.JsonEncodedText MemberDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText MemberCreated = System.Text.Json.JsonEncodedText.Encode("created"); + + public override Result Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "updated": - return Result.Updated; - case "not_found": - return Result.NotFound; - case "noop": - return Result.NoOp; - case "deleted": - return Result.Deleted; - case "created": - return Result.Created; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUpdated)) + { + return Result.Updated; + } + + if (reader.ValueTextEquals(MemberNotFound)) + { + return Result.NotFound; + } + + if (reader.ValueTextEquals(MemberNoOp)) + { + return Result.NoOp; + } + + if (reader.ValueTextEquals(MemberDeleted)) + { + return Result.Deleted; + } + + if (reader.ValueTextEquals(MemberCreated)) + { + return Result.Created; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Result)}'."); } - public override void Write(Utf8JsonWriter writer, Result value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Result value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Result.Updated: - writer.WriteStringValue("updated"); - return; + writer.WriteStringValue(MemberUpdated); + break; case Result.NotFound: - writer.WriteStringValue("not_found"); - return; + writer.WriteStringValue(MemberNotFound); + break; case Result.NoOp: - writer.WriteStringValue("noop"); - return; + writer.WriteStringValue(MemberNoOp); + break; case Result.Deleted: - writer.WriteStringValue("deleted"); - return; + writer.WriteStringValue(MemberDeleted); + break; case Result.Created: - writer.WriteStringValue("created"); - return; + writer.WriteStringValue(MemberCreated); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Result)}'."); } - - writer.WriteNullValue(); } } @@ -1250,9 +1519,11 @@ public override void Write(Utf8JsonWriter writer, Result value, JsonSerializerOp public readonly partial struct ScriptLanguage : IEnumStruct { public ScriptLanguage(string value) => Value = value; - +#if NET7_0_OR_GREATER + static ScriptLanguage IEnumStruct.Create(string value) => value; +#else ScriptLanguage IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -1307,41 +1578,49 @@ public enum ScriptSortType Number } -internal sealed class ScriptSortTypeConverter : JsonConverter +internal sealed partial class ScriptSortTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ScriptSortType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberNumber = System.Text.Json.JsonEncodedText.Encode("number"); + + public override ScriptSortType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return ScriptSortType.Version; + } + + if (reader.ValueTextEquals(MemberString)) + { + return ScriptSortType.String; + } + + if (reader.ValueTextEquals(MemberNumber)) { - case "version": - return ScriptSortType.Version; - case "string": - return ScriptSortType.String; - case "number": - return ScriptSortType.Number; + return ScriptSortType.Number; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ScriptSortType)}'."); } - public override void Write(Utf8JsonWriter writer, ScriptSortType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScriptSortType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ScriptSortType.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case ScriptSortType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ScriptSortType.Number: - writer.WriteStringValue("number"); - return; + writer.WriteStringValue(MemberNumber); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ScriptSortType)}'."); } - - writer.WriteNullValue(); } } @@ -1364,36 +1643,40 @@ public enum SearchType DfsQueryThenFetch } -internal sealed class SearchTypeConverter : JsonConverter +internal sealed partial class SearchTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override SearchType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberQueryThenFetch = System.Text.Json.JsonEncodedText.Encode("query_then_fetch"); + private static readonly System.Text.Json.JsonEncodedText MemberDfsQueryThenFetch = System.Text.Json.JsonEncodedText.Encode("dfs_query_then_fetch"); + + public override SearchType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberQueryThenFetch)) { - case "query_then_fetch": - return SearchType.QueryThenFetch; - case "dfs_query_then_fetch": - return SearchType.DfsQueryThenFetch; + return SearchType.QueryThenFetch; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDfsQueryThenFetch)) + { + return SearchType.DfsQueryThenFetch; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SearchType)}'."); } - public override void Write(Utf8JsonWriter writer, SearchType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SearchType.QueryThenFetch: - writer.WriteStringValue("query_then_fetch"); - return; + writer.WriteStringValue(MemberQueryThenFetch); + break; case SearchType.DfsQueryThenFetch: - writer.WriteStringValue("dfs_query_then_fetch"); - return; + writer.WriteStringValue(MemberDfsQueryThenFetch); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SearchType)}'."); } - - writer.WriteNullValue(); } } @@ -1409,31 +1692,31 @@ public enum SlicesCalculation Auto } -internal sealed class SlicesCalculationConverter : JsonConverter +internal sealed partial class SlicesCalculationConverter : System.Text.Json.Serialization.JsonConverter { - public override SlicesCalculation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override SlicesCalculation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberAuto)) { - case "auto": - return SlicesCalculation.Auto; + return SlicesCalculation.Auto; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SlicesCalculation)}'."); } - public override void Write(Utf8JsonWriter writer, SlicesCalculation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SlicesCalculation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SlicesCalculation.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SlicesCalculation)}'."); } - - writer.WriteNullValue(); } } @@ -1452,51 +1735,67 @@ public enum SortMode Avg } -internal sealed class SortModeConverter : JsonConverter +internal sealed partial class SortModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SortMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMedian = System.Text.Json.JsonEncodedText.Encode("median"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override SortMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return SortMode.Sum; - case "min": - return SortMode.Min; - case "median": - return SortMode.Median; - case "max": - return SortMode.Max; - case "avg": - return SortMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return SortMode.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return SortMode.Min; + } + + if (reader.ValueTextEquals(MemberMedian)) + { + return SortMode.Median; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return SortMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return SortMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SortMode)}'."); } - public override void Write(Utf8JsonWriter writer, SortMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SortMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SortMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case SortMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case SortMode.Median: - writer.WriteStringValue("median"); - return; + writer.WriteStringValue(MemberMedian); + break; case SortMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case SortMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SortMode)}'."); } - - writer.WriteNullValue(); } } @@ -1519,36 +1818,40 @@ public enum SortOrder Asc } -internal sealed class SortOrderConverter : JsonConverter +internal sealed partial class SortOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override SortOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDesc = System.Text.Json.JsonEncodedText.Encode("desc"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc = System.Text.Json.JsonEncodedText.Encode("asc"); + + public override SortOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDesc)) + { + return SortOrder.Desc; + } + + if (reader.ValueTextEquals(MemberAsc)) { - case "desc": - return SortOrder.Desc; - case "asc": - return SortOrder.Asc; + return SortOrder.Asc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SortOrder)}'."); } - public override void Write(Utf8JsonWriter writer, SortOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SortOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SortOrder.Desc: - writer.WriteStringValue("desc"); - return; + writer.WriteStringValue(MemberDesc); + break; case SortOrder.Asc: - writer.WriteStringValue("asc"); - return; + writer.WriteStringValue(MemberAsc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SortOrder)}'."); } - - writer.WriteNullValue(); } } @@ -1578,41 +1881,49 @@ public enum SuggestMode Always } -internal sealed class SuggestModeConverter : JsonConverter +internal sealed partial class SuggestModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SuggestMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPopular = System.Text.Json.JsonEncodedText.Encode("popular"); + private static readonly System.Text.Json.JsonEncodedText MemberMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("always"); + + public override SuggestMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPopular)) + { + return SuggestMode.Popular; + } + + if (reader.ValueTextEquals(MemberMissing)) + { + return SuggestMode.Missing; + } + + if (reader.ValueTextEquals(MemberAlways)) { - case "popular": - return SuggestMode.Popular; - case "missing": - return SuggestMode.Missing; - case "always": - return SuggestMode.Always; + return SuggestMode.Always; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SuggestMode)}'."); } - public override void Write(Utf8JsonWriter writer, SuggestMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SuggestMode.Popular: - writer.WriteStringValue("popular"); - return; + writer.WriteStringValue(MemberPopular); + break; case SuggestMode.Missing: - writer.WriteStringValue("missing"); - return; + writer.WriteStringValue(MemberMissing); + break; case SuggestMode.Always: - writer.WriteStringValue("always"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SuggestMode)}'."); } - - writer.WriteNullValue(); } } @@ -1631,51 +1942,67 @@ public enum ThreadType Block } -internal sealed class ThreadTypeConverter : JsonConverter +internal sealed partial class ThreadTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ThreadType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWait = System.Text.Json.JsonEncodedText.Encode("wait"); + private static readonly System.Text.Json.JsonEncodedText MemberMem = System.Text.Json.JsonEncodedText.Encode("mem"); + private static readonly System.Text.Json.JsonEncodedText MemberGpu = System.Text.Json.JsonEncodedText.Encode("gpu"); + private static readonly System.Text.Json.JsonEncodedText MemberCpu = System.Text.Json.JsonEncodedText.Encode("cpu"); + private static readonly System.Text.Json.JsonEncodedText MemberBlock = System.Text.Json.JsonEncodedText.Encode("block"); + + public override ThreadType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "wait": - return ThreadType.Wait; - case "mem": - return ThreadType.Mem; - case "gpu": - return ThreadType.Gpu; - case "cpu": - return ThreadType.Cpu; - case "block": - return ThreadType.Block; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWait)) + { + return ThreadType.Wait; + } + + if (reader.ValueTextEquals(MemberMem)) + { + return ThreadType.Mem; + } + + if (reader.ValueTextEquals(MemberGpu)) + { + return ThreadType.Gpu; + } + + if (reader.ValueTextEquals(MemberCpu)) + { + return ThreadType.Cpu; + } + + if (reader.ValueTextEquals(MemberBlock)) + { + return ThreadType.Block; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ThreadType)}'."); } - public override void Write(Utf8JsonWriter writer, ThreadType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ThreadType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ThreadType.Wait: - writer.WriteStringValue("wait"); - return; + writer.WriteStringValue(MemberWait); + break; case ThreadType.Mem: - writer.WriteStringValue("mem"); - return; + writer.WriteStringValue(MemberMem); + break; case ThreadType.Gpu: - writer.WriteStringValue("gpu"); - return; + writer.WriteStringValue(MemberGpu); + break; case ThreadType.Cpu: - writer.WriteStringValue("cpu"); - return; + writer.WriteStringValue(MemberCpu); + break; case ThreadType.Block: - writer.WriteStringValue("block"); - return; + writer.WriteStringValue(MemberBlock); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ThreadType)}'."); } - - writer.WriteNullValue(); } } @@ -1698,61 +2025,85 @@ public enum TimeUnit Days } -internal sealed class TimeUnitConverter : JsonConverter +internal sealed partial class TimeUnitConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeUnit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSeconds = System.Text.Json.JsonEncodedText.Encode("s"); + private static readonly System.Text.Json.JsonEncodedText MemberNanoseconds = System.Text.Json.JsonEncodedText.Encode("nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberMinutes = System.Text.Json.JsonEncodedText.Encode("m"); + private static readonly System.Text.Json.JsonEncodedText MemberMilliseconds = System.Text.Json.JsonEncodedText.Encode("ms"); + private static readonly System.Text.Json.JsonEncodedText MemberMicroseconds = System.Text.Json.JsonEncodedText.Encode("micros"); + private static readonly System.Text.Json.JsonEncodedText MemberHours = System.Text.Json.JsonEncodedText.Encode("h"); + private static readonly System.Text.Json.JsonEncodedText MemberDays = System.Text.Json.JsonEncodedText.Encode("d"); + + public override TimeUnit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "s": - return TimeUnit.Seconds; - case "nanos": - return TimeUnit.Nanoseconds; - case "m": - return TimeUnit.Minutes; - case "ms": - return TimeUnit.Milliseconds; - case "micros": - return TimeUnit.Microseconds; - case "h": - return TimeUnit.Hours; - case "d": - return TimeUnit.Days; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSeconds)) + { + return TimeUnit.Seconds; + } + + if (reader.ValueTextEquals(MemberNanoseconds)) + { + return TimeUnit.Nanoseconds; + } + + if (reader.ValueTextEquals(MemberMinutes)) + { + return TimeUnit.Minutes; + } + + if (reader.ValueTextEquals(MemberMilliseconds)) + { + return TimeUnit.Milliseconds; + } + + if (reader.ValueTextEquals(MemberMicroseconds)) + { + return TimeUnit.Microseconds; + } + + if (reader.ValueTextEquals(MemberHours)) + { + return TimeUnit.Hours; + } + + if (reader.ValueTextEquals(MemberDays)) + { + return TimeUnit.Days; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TimeUnit)}'."); } - public override void Write(Utf8JsonWriter writer, TimeUnit value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeUnit value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TimeUnit.Seconds: - writer.WriteStringValue("s"); - return; + writer.WriteStringValue(MemberSeconds); + break; case TimeUnit.Nanoseconds: - writer.WriteStringValue("nanos"); - return; + writer.WriteStringValue(MemberNanoseconds); + break; case TimeUnit.Minutes: - writer.WriteStringValue("m"); - return; + writer.WriteStringValue(MemberMinutes); + break; case TimeUnit.Milliseconds: - writer.WriteStringValue("ms"); - return; + writer.WriteStringValue(MemberMilliseconds); + break; case TimeUnit.Microseconds: - writer.WriteStringValue("micros"); - return; + writer.WriteStringValue(MemberMicroseconds); + break; case TimeUnit.Hours: - writer.WriteStringValue("h"); - return; + writer.WriteStringValue(MemberHours); + break; case TimeUnit.Days: - writer.WriteStringValue("d"); - return; + writer.WriteStringValue(MemberDays); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TimeUnit)}'."); } - - writer.WriteNullValue(); } } @@ -1786,46 +2137,58 @@ public enum VersionType External } -internal sealed class VersionTypeConverter : JsonConverter +internal sealed partial class VersionTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override VersionType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInternal = System.Text.Json.JsonEncodedText.Encode("internal"); + private static readonly System.Text.Json.JsonEncodedText MemberForce = System.Text.Json.JsonEncodedText.Encode("force"); + private static readonly System.Text.Json.JsonEncodedText MemberExternalGte = System.Text.Json.JsonEncodedText.Encode("external_gte"); + private static readonly System.Text.Json.JsonEncodedText MemberExternal = System.Text.Json.JsonEncodedText.Encode("external"); + + public override VersionType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInternal)) + { + return VersionType.Internal; + } + + if (reader.ValueTextEquals(MemberForce)) + { + return VersionType.Force; + } + + if (reader.ValueTextEquals(MemberExternalGte)) { - case "internal": - return VersionType.Internal; - case "force": - return VersionType.Force; - case "external_gte": - return VersionType.ExternalGte; - case "external": - return VersionType.External; + return VersionType.ExternalGte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExternal)) + { + return VersionType.External; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(VersionType)}'."); } - public override void Write(Utf8JsonWriter writer, VersionType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, VersionType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case VersionType.Internal: - writer.WriteStringValue("internal"); - return; + writer.WriteStringValue(MemberInternal); + break; case VersionType.Force: - writer.WriteStringValue("force"); - return; + writer.WriteStringValue(MemberForce); + break; case VersionType.ExternalGte: - writer.WriteStringValue("external_gte"); - return; + writer.WriteStringValue(MemberExternalGte); + break; case VersionType.External: - writer.WriteStringValue("external"); - return; + writer.WriteStringValue(MemberExternal); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(VersionType)}'."); } - - writer.WriteNullValue(); } } @@ -1846,55 +2209,75 @@ public enum WaitForEvents High } -internal sealed class WaitForEventsConverter : JsonConverter +internal sealed partial class WaitForEventsConverter : System.Text.Json.Serialization.JsonConverter { - public override WaitForEvents Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUrgent = System.Text.Json.JsonEncodedText.Encode("urgent"); + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberLow = System.Text.Json.JsonEncodedText.Encode("low"); + private static readonly System.Text.Json.JsonEncodedText MemberLanguid = System.Text.Json.JsonEncodedText.Encode("languid"); + private static readonly System.Text.Json.JsonEncodedText MemberImmediate = System.Text.Json.JsonEncodedText.Encode("immediate"); + private static readonly System.Text.Json.JsonEncodedText MemberHigh = System.Text.Json.JsonEncodedText.Encode("high"); + + public override WaitForEvents Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "urgent": - return WaitForEvents.Urgent; - case "normal": - return WaitForEvents.Normal; - case "low": - return WaitForEvents.Low; - case "languid": - return WaitForEvents.Languid; - case "immediate": - return WaitForEvents.Immediate; - case "high": - return WaitForEvents.High; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUrgent)) + { + return WaitForEvents.Urgent; + } + + if (reader.ValueTextEquals(MemberNormal)) + { + return WaitForEvents.Normal; + } + + if (reader.ValueTextEquals(MemberLow)) + { + return WaitForEvents.Low; + } + + if (reader.ValueTextEquals(MemberLanguid)) + { + return WaitForEvents.Languid; + } + + if (reader.ValueTextEquals(MemberImmediate)) + { + return WaitForEvents.Immediate; + } + + if (reader.ValueTextEquals(MemberHigh)) + { + return WaitForEvents.High; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(WaitForEvents)}'."); } - public override void Write(Utf8JsonWriter writer, WaitForEvents value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, WaitForEvents value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case WaitForEvents.Urgent: - writer.WriteStringValue("urgent"); - return; + writer.WriteStringValue(MemberUrgent); + break; case WaitForEvents.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case WaitForEvents.Low: - writer.WriteStringValue("low"); - return; + writer.WriteStringValue(MemberLow); + break; case WaitForEvents.Languid: - writer.WriteStringValue("languid"); - return; + writer.WriteStringValue(MemberLanguid); + break; case WaitForEvents.Immediate: - writer.WriteStringValue("immediate"); - return; + writer.WriteStringValue(MemberImmediate); + break; case WaitForEvents.High: - writer.WriteStringValue("high"); - return; + writer.WriteStringValue(MemberHigh); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(WaitForEvents)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryDsl.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryDsl.g.cs index e5e98a0d91a..2dff5b4f356 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryDsl.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryDsl.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -43,51 +44,67 @@ public enum ChildScoreMode Avg } -internal sealed class ChildScoreModeConverter : JsonConverter +internal sealed partial class ChildScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ChildScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override ChildScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return ChildScoreMode.Sum; - case "none": - return ChildScoreMode.None; - case "min": - return ChildScoreMode.Min; - case "max": - return ChildScoreMode.Max; - case "avg": - return ChildScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return ChildScoreMode.Sum; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ChildScoreMode.None; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return ChildScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return ChildScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return ChildScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ChildScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, ChildScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChildScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ChildScoreMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case ChildScoreMode.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ChildScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case ChildScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case ChildScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ChildScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -100,36 +117,40 @@ public enum CombinedFieldsOperator And } -internal sealed class CombinedFieldsOperatorConverter : JsonConverter +internal sealed partial class CombinedFieldsOperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override CombinedFieldsOperator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOr = System.Text.Json.JsonEncodedText.Encode("or"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd = System.Text.Json.JsonEncodedText.Encode("and"); + + public override CombinedFieldsOperator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOr)) + { + return CombinedFieldsOperator.Or; + } + + if (reader.ValueTextEquals(MemberAnd)) { - case "or": - return CombinedFieldsOperator.Or; - case "and": - return CombinedFieldsOperator.And; + return CombinedFieldsOperator.And; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CombinedFieldsOperator)}'."); } - public override void Write(Utf8JsonWriter writer, CombinedFieldsOperator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsOperator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CombinedFieldsOperator.Or: - writer.WriteStringValue("or"); - return; + writer.WriteStringValue(MemberOr); + break; case CombinedFieldsOperator.And: - writer.WriteStringValue("and"); - return; + writer.WriteStringValue(MemberAnd); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CombinedFieldsOperator)}'."); } - - writer.WriteNullValue(); } } @@ -152,36 +173,40 @@ public enum CombinedFieldsZeroTerms All } -internal sealed class CombinedFieldsZeroTermsConverter : JsonConverter +internal sealed partial class CombinedFieldsZeroTermsConverter : System.Text.Json.Serialization.JsonConverter { - public override CombinedFieldsZeroTerms Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override CombinedFieldsZeroTerms Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) + { + return CombinedFieldsZeroTerms.None; + } + + if (reader.ValueTextEquals(MemberAll)) { - case "none": - return CombinedFieldsZeroTerms.None; - case "all": - return CombinedFieldsZeroTerms.All; + return CombinedFieldsZeroTerms.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CombinedFieldsZeroTerms)}'."); } - public override void Write(Utf8JsonWriter writer, CombinedFieldsZeroTerms value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsZeroTerms value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CombinedFieldsZeroTerms.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case CombinedFieldsZeroTerms.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CombinedFieldsZeroTerms)}'."); } - - writer.WriteNullValue(); } } @@ -262,76 +287,112 @@ public enum FieldValueFactorModifier Ln } -internal sealed class FieldValueFactorModifierConverter : JsonConverter +internal sealed partial class FieldValueFactorModifierConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldValueFactorModifier Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSquare = System.Text.Json.JsonEncodedText.Encode("square"); + private static readonly System.Text.Json.JsonEncodedText MemberSqrt = System.Text.Json.JsonEncodedText.Encode("sqrt"); + private static readonly System.Text.Json.JsonEncodedText MemberReciprocal = System.Text.Json.JsonEncodedText.Encode("reciprocal"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberLog2p = System.Text.Json.JsonEncodedText.Encode("log2p"); + private static readonly System.Text.Json.JsonEncodedText MemberLog1p = System.Text.Json.JsonEncodedText.Encode("log1p"); + private static readonly System.Text.Json.JsonEncodedText MemberLog = System.Text.Json.JsonEncodedText.Encode("log"); + private static readonly System.Text.Json.JsonEncodedText MemberLn2p = System.Text.Json.JsonEncodedText.Encode("ln2p"); + private static readonly System.Text.Json.JsonEncodedText MemberLn1p = System.Text.Json.JsonEncodedText.Encode("ln1p"); + private static readonly System.Text.Json.JsonEncodedText MemberLn = System.Text.Json.JsonEncodedText.Encode("ln"); + + public override FieldValueFactorModifier Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "square": - return FieldValueFactorModifier.Square; - case "sqrt": - return FieldValueFactorModifier.Sqrt; - case "reciprocal": - return FieldValueFactorModifier.Reciprocal; - case "none": - return FieldValueFactorModifier.None; - case "log2p": - return FieldValueFactorModifier.Log2p; - case "log1p": - return FieldValueFactorModifier.Log1p; - case "log": - return FieldValueFactorModifier.Log; - case "ln2p": - return FieldValueFactorModifier.Ln2p; - case "ln1p": - return FieldValueFactorModifier.Ln1p; - case "ln": - return FieldValueFactorModifier.Ln; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSquare)) + { + return FieldValueFactorModifier.Square; + } + + if (reader.ValueTextEquals(MemberSqrt)) + { + return FieldValueFactorModifier.Sqrt; + } + + if (reader.ValueTextEquals(MemberReciprocal)) + { + return FieldValueFactorModifier.Reciprocal; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return FieldValueFactorModifier.None; + } + + if (reader.ValueTextEquals(MemberLog2p)) + { + return FieldValueFactorModifier.Log2p; + } + + if (reader.ValueTextEquals(MemberLog1p)) + { + return FieldValueFactorModifier.Log1p; + } + + if (reader.ValueTextEquals(MemberLog)) + { + return FieldValueFactorModifier.Log; + } + + if (reader.ValueTextEquals(MemberLn2p)) + { + return FieldValueFactorModifier.Ln2p; + } + + if (reader.ValueTextEquals(MemberLn1p)) + { + return FieldValueFactorModifier.Ln1p; + } + + if (reader.ValueTextEquals(MemberLn)) + { + return FieldValueFactorModifier.Ln; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldValueFactorModifier)}'."); } - public override void Write(Utf8JsonWriter writer, FieldValueFactorModifier value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldValueFactorModifier value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldValueFactorModifier.Square: - writer.WriteStringValue("square"); - return; + writer.WriteStringValue(MemberSquare); + break; case FieldValueFactorModifier.Sqrt: - writer.WriteStringValue("sqrt"); - return; + writer.WriteStringValue(MemberSqrt); + break; case FieldValueFactorModifier.Reciprocal: - writer.WriteStringValue("reciprocal"); - return; + writer.WriteStringValue(MemberReciprocal); + break; case FieldValueFactorModifier.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case FieldValueFactorModifier.Log2p: - writer.WriteStringValue("log2p"); - return; + writer.WriteStringValue(MemberLog2p); + break; case FieldValueFactorModifier.Log1p: - writer.WriteStringValue("log1p"); - return; + writer.WriteStringValue(MemberLog1p); + break; case FieldValueFactorModifier.Log: - writer.WriteStringValue("log"); - return; + writer.WriteStringValue(MemberLog); + break; case FieldValueFactorModifier.Ln2p: - writer.WriteStringValue("ln2p"); - return; + writer.WriteStringValue(MemberLn2p); + break; case FieldValueFactorModifier.Ln1p: - writer.WriteStringValue("ln1p"); - return; + writer.WriteStringValue(MemberLn1p); + break; case FieldValueFactorModifier.Ln: - writer.WriteStringValue("ln"); - return; + writer.WriteStringValue(MemberLn); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldValueFactorModifier)}'."); } - - writer.WriteNullValue(); } } @@ -383,56 +444,76 @@ public enum FunctionBoostMode Avg } -internal sealed class FunctionBoostModeConverter : JsonConverter +internal sealed partial class FunctionBoostModeConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionBoostMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override FunctionBoostMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return FunctionBoostMode.Sum; - case "replace": - return FunctionBoostMode.Replace; - case "multiply": - return FunctionBoostMode.Multiply; - case "min": - return FunctionBoostMode.Min; - case "max": - return FunctionBoostMode.Max; - case "avg": - return FunctionBoostMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return FunctionBoostMode.Sum; + } + + if (reader.ValueTextEquals(MemberReplace)) + { + return FunctionBoostMode.Replace; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return FunctionBoostMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return FunctionBoostMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return FunctionBoostMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return FunctionBoostMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FunctionBoostMode)}'."); } - public override void Write(Utf8JsonWriter writer, FunctionBoostMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionBoostMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FunctionBoostMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case FunctionBoostMode.Replace: - writer.WriteStringValue("replace"); - return; + writer.WriteStringValue(MemberReplace); + break; case FunctionBoostMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case FunctionBoostMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case FunctionBoostMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case FunctionBoostMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FunctionBoostMode)}'."); } - - writer.WriteNullValue(); } } @@ -483,56 +564,76 @@ public enum FunctionScoreMode Avg } -internal sealed class FunctionScoreModeConverter : JsonConverter +internal sealed partial class FunctionScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override FunctionScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return FunctionScoreMode.Sum; - case "multiply": - return FunctionScoreMode.Multiply; - case "min": - return FunctionScoreMode.Min; - case "max": - return FunctionScoreMode.Max; - case "first": - return FunctionScoreMode.First; - case "avg": - return FunctionScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return FunctionScoreMode.Sum; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return FunctionScoreMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return FunctionScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return FunctionScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return FunctionScoreMode.First; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return FunctionScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FunctionScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, FunctionScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FunctionScoreMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case FunctionScoreMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case FunctionScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case FunctionScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case FunctionScoreMode.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; case FunctionScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FunctionScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -557,41 +658,49 @@ public enum GeoValidationMethod Coerce } -internal sealed class GeoValidationMethodConverter : JsonConverter +internal sealed partial class GeoValidationMethodConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoValidationMethod Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStrict = System.Text.Json.JsonEncodedText.Encode("strict"); + private static readonly System.Text.Json.JsonEncodedText MemberIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText MemberCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + + public override GeoValidationMethod Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStrict)) + { + return GeoValidationMethod.Strict; + } + + if (reader.ValueTextEquals(MemberIgnoreMalformed)) { - case "strict": - return GeoValidationMethod.Strict; - case "ignore_malformed": - return GeoValidationMethod.IgnoreMalformed; - case "coerce": - return GeoValidationMethod.Coerce; + return GeoValidationMethod.IgnoreMalformed; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCoerce)) + { + return GeoValidationMethod.Coerce; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoValidationMethod)}'."); } - public override void Write(Utf8JsonWriter writer, GeoValidationMethod value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoValidationMethod value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoValidationMethod.Strict: - writer.WriteStringValue("strict"); - return; + writer.WriteStringValue(MemberStrict); + break; case GeoValidationMethod.IgnoreMalformed: - writer.WriteStringValue("ignore_malformed"); - return; + writer.WriteStringValue(MemberIgnoreMalformed); + break; case GeoValidationMethod.Coerce: - writer.WriteStringValue("coerce"); - return; + writer.WriteStringValue(MemberCoerce); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoValidationMethod)}'."); } - - writer.WriteNullValue(); } } @@ -628,46 +737,58 @@ public enum MultiValueMode Avg } -internal sealed class MultiValueModeConverter : JsonConverter +internal sealed partial class MultiValueModeConverter : System.Text.Json.Serialization.JsonConverter { - public override MultiValueMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override MultiValueMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return MultiValueMode.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return MultiValueMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return MultiValueMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) { - case "sum": - return MultiValueMode.Sum; - case "min": - return MultiValueMode.Min; - case "max": - return MultiValueMode.Max; - case "avg": - return MultiValueMode.Avg; + return MultiValueMode.Avg; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MultiValueMode)}'."); } - public override void Write(Utf8JsonWriter writer, MultiValueMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiValueMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MultiValueMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case MultiValueMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case MultiValueMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case MultiValueMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MultiValueMode)}'."); } - - writer.WriteNullValue(); } } @@ -680,38 +801,42 @@ public enum Operator And } -internal sealed class OperatorConverter : JsonConverter +internal sealed partial class OperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override Operator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOr = System.Text.Json.JsonEncodedText.Encode("or"); + private static readonly System.Text.Json.JsonEncodedText MemberOr1 = System.Text.Json.JsonEncodedText.Encode("OR"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd = System.Text.Json.JsonEncodedText.Encode("and"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd1 = System.Text.Json.JsonEncodedText.Encode("AND"); + + public override Operator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOr) || reader.ValueTextEquals(MemberOr1)) + { + return Operator.Or; + } + + if (reader.ValueTextEquals(MemberAnd) || reader.ValueTextEquals(MemberAnd1)) { - case "or": - case "OR": - return Operator.Or; - case "and": - case "AND": - return Operator.And; + return Operator.And; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Operator)}'."); } - public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Operator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Operator.Or: - writer.WriteStringValue("or"); - return; + writer.WriteStringValue(MemberOr); + break; case Operator.And: - writer.WriteStringValue("and"); - return; + writer.WriteStringValue(MemberAnd); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Operator)}'."); } - - writer.WriteNullValue(); } } @@ -741,41 +866,49 @@ public enum RangeRelation Contains } -internal sealed class RangeRelationConverter : JsonConverter +internal sealed partial class RangeRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override RangeRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWithin = System.Text.Json.JsonEncodedText.Encode("within"); + private static readonly System.Text.Json.JsonEncodedText MemberIntersects = System.Text.Json.JsonEncodedText.Encode("intersects"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + + public override RangeRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWithin)) + { + return RangeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) { - case "within": - return RangeRelation.Within; - case "intersects": - return RangeRelation.Intersects; - case "contains": - return RangeRelation.Contains; + return RangeRelation.Intersects; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberContains)) + { + return RangeRelation.Contains; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RangeRelation)}'."); } - public override void Write(Utf8JsonWriter writer, RangeRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RangeRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RangeRelation.Within: - writer.WriteStringValue("within"); - return; + writer.WriteStringValue(MemberWithin); + break; case RangeRelation.Intersects: - writer.WriteStringValue("intersects"); - return; + writer.WriteStringValue(MemberIntersects); + break; case RangeRelation.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RangeRelation)}'."); } - - writer.WriteNullValue(); } } @@ -1008,56 +1141,76 @@ public enum TextQueryType BestFields } -internal sealed class TextQueryTypeConverter : JsonConverter +internal sealed partial class TextQueryTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TextQueryType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPhrasePrefix = System.Text.Json.JsonEncodedText.Encode("phrase_prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberPhrase = System.Text.Json.JsonEncodedText.Encode("phrase"); + private static readonly System.Text.Json.JsonEncodedText MemberMostFields = System.Text.Json.JsonEncodedText.Encode("most_fields"); + private static readonly System.Text.Json.JsonEncodedText MemberCrossFields = System.Text.Json.JsonEncodedText.Encode("cross_fields"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolPrefix = System.Text.Json.JsonEncodedText.Encode("bool_prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberBestFields = System.Text.Json.JsonEncodedText.Encode("best_fields"); + + public override TextQueryType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "phrase_prefix": - return TextQueryType.PhrasePrefix; - case "phrase": - return TextQueryType.Phrase; - case "most_fields": - return TextQueryType.MostFields; - case "cross_fields": - return TextQueryType.CrossFields; - case "bool_prefix": - return TextQueryType.BoolPrefix; - case "best_fields": - return TextQueryType.BestFields; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPhrasePrefix)) + { + return TextQueryType.PhrasePrefix; + } + + if (reader.ValueTextEquals(MemberPhrase)) + { + return TextQueryType.Phrase; + } + + if (reader.ValueTextEquals(MemberMostFields)) + { + return TextQueryType.MostFields; + } + + if (reader.ValueTextEquals(MemberCrossFields)) + { + return TextQueryType.CrossFields; + } + + if (reader.ValueTextEquals(MemberBoolPrefix)) + { + return TextQueryType.BoolPrefix; + } + + if (reader.ValueTextEquals(MemberBestFields)) + { + return TextQueryType.BestFields; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TextQueryType)}'."); } - public override void Write(Utf8JsonWriter writer, TextQueryType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TextQueryType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TextQueryType.PhrasePrefix: - writer.WriteStringValue("phrase_prefix"); - return; + writer.WriteStringValue(MemberPhrasePrefix); + break; case TextQueryType.Phrase: - writer.WriteStringValue("phrase"); - return; + writer.WriteStringValue(MemberPhrase); + break; case TextQueryType.MostFields: - writer.WriteStringValue("most_fields"); - return; + writer.WriteStringValue(MemberMostFields); + break; case TextQueryType.CrossFields: - writer.WriteStringValue("cross_fields"); - return; + writer.WriteStringValue(MemberCrossFields); + break; case TextQueryType.BoolPrefix: - writer.WriteStringValue("bool_prefix"); - return; + writer.WriteStringValue(MemberBoolPrefix); + break; case TextQueryType.BestFields: - writer.WriteStringValue("best_fields"); - return; + writer.WriteStringValue(MemberBestFields); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TextQueryType)}'."); } - - writer.WriteNullValue(); } } @@ -1080,35 +1233,39 @@ public enum ZeroTermsQuery All } -internal sealed class ZeroTermsQueryConverter : JsonConverter +internal sealed partial class ZeroTermsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override ZeroTermsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ZeroTermsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) { - case "none": - return ZeroTermsQuery.None; - case "all": - return ZeroTermsQuery.All; + return ZeroTermsQuery.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAll)) + { + return ZeroTermsQuery.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ZeroTermsQuery)}'."); } - public override void Write(Utf8JsonWriter writer, ZeroTermsQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ZeroTermsQuery value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ZeroTermsQuery.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ZeroTermsQuery.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ZeroTermsQuery)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryRules.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryRules.g.cs index a363213625d..bb60d19a30a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryRules.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.QueryRules.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -57,86 +58,130 @@ public enum QueryRuleCriteriaType Always } -internal sealed class QueryRuleCriteriaTypeConverter : JsonConverter +internal sealed partial class QueryRuleCriteriaTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryRuleCriteriaType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSuffix = System.Text.Json.JsonEncodedText.Encode("suffix"); + private static readonly System.Text.Json.JsonEncodedText MemberPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText MemberLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText MemberFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText MemberExactFuzzy = System.Text.Json.JsonEncodedText.Encode("exact_fuzzy"); + private static readonly System.Text.Json.JsonEncodedText MemberExact = System.Text.Json.JsonEncodedText.Encode("exact"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("always"); + + public override QueryRuleCriteriaType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "suffix": - return QueryRuleCriteriaType.Suffix; - case "prefix": - return QueryRuleCriteriaType.Prefix; - case "lte": - return QueryRuleCriteriaType.Lte; - case "lt": - return QueryRuleCriteriaType.Lt; - case "gte": - return QueryRuleCriteriaType.Gte; - case "gt": - return QueryRuleCriteriaType.Gt; - case "global": - return QueryRuleCriteriaType.Global; - case "fuzzy": - return QueryRuleCriteriaType.Fuzzy; - case "exact_fuzzy": - return QueryRuleCriteriaType.ExactFuzzy; - case "exact": - return QueryRuleCriteriaType.Exact; - case "contains": - return QueryRuleCriteriaType.Contains; - case "always": - return QueryRuleCriteriaType.Always; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSuffix)) + { + return QueryRuleCriteriaType.Suffix; + } + + if (reader.ValueTextEquals(MemberPrefix)) + { + return QueryRuleCriteriaType.Prefix; + } + + if (reader.ValueTextEquals(MemberLte)) + { + return QueryRuleCriteriaType.Lte; + } + + if (reader.ValueTextEquals(MemberLt)) + { + return QueryRuleCriteriaType.Lt; + } + + if (reader.ValueTextEquals(MemberGte)) + { + return QueryRuleCriteriaType.Gte; + } + + if (reader.ValueTextEquals(MemberGt)) + { + return QueryRuleCriteriaType.Gt; + } + + if (reader.ValueTextEquals(MemberGlobal)) + { + return QueryRuleCriteriaType.Global; + } + + if (reader.ValueTextEquals(MemberFuzzy)) + { + return QueryRuleCriteriaType.Fuzzy; + } + + if (reader.ValueTextEquals(MemberExactFuzzy)) + { + return QueryRuleCriteriaType.ExactFuzzy; + } + + if (reader.ValueTextEquals(MemberExact)) + { + return QueryRuleCriteriaType.Exact; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return QueryRuleCriteriaType.Contains; + } + + if (reader.ValueTextEquals(MemberAlways)) + { + return QueryRuleCriteriaType.Always; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(QueryRuleCriteriaType)}'."); } - public override void Write(Utf8JsonWriter writer, QueryRuleCriteriaType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRuleCriteriaType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case QueryRuleCriteriaType.Suffix: - writer.WriteStringValue("suffix"); - return; + writer.WriteStringValue(MemberSuffix); + break; case QueryRuleCriteriaType.Prefix: - writer.WriteStringValue("prefix"); - return; + writer.WriteStringValue(MemberPrefix); + break; case QueryRuleCriteriaType.Lte: - writer.WriteStringValue("lte"); - return; + writer.WriteStringValue(MemberLte); + break; case QueryRuleCriteriaType.Lt: - writer.WriteStringValue("lt"); - return; + writer.WriteStringValue(MemberLt); + break; case QueryRuleCriteriaType.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case QueryRuleCriteriaType.Gt: - writer.WriteStringValue("gt"); - return; + writer.WriteStringValue(MemberGt); + break; case QueryRuleCriteriaType.Global: - writer.WriteStringValue("global"); - return; + writer.WriteStringValue(MemberGlobal); + break; case QueryRuleCriteriaType.Fuzzy: - writer.WriteStringValue("fuzzy"); - return; + writer.WriteStringValue(MemberFuzzy); + break; case QueryRuleCriteriaType.ExactFuzzy: - writer.WriteStringValue("exact_fuzzy"); - return; + writer.WriteStringValue(MemberExactFuzzy); + break; case QueryRuleCriteriaType.Exact: - writer.WriteStringValue("exact"); - return; + writer.WriteStringValue(MemberExact); + break; case QueryRuleCriteriaType.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; case QueryRuleCriteriaType.Always: - writer.WriteStringValue("always"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(QueryRuleCriteriaType)}'."); } - - writer.WriteNullValue(); } } @@ -149,35 +194,39 @@ public enum QueryRuleType Exclude } -internal sealed class QueryRuleTypeConverter : JsonConverter +internal sealed partial class QueryRuleTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryRuleType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPinned = System.Text.Json.JsonEncodedText.Encode("pinned"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override QueryRuleType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPinned)) { - case "pinned": - return QueryRuleType.Pinned; - case "exclude": - return QueryRuleType.Exclude; + return QueryRuleType.Pinned; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExclude)) + { + return QueryRuleType.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(QueryRuleType)}'."); } - public override void Write(Utf8JsonWriter writer, QueryRuleType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRuleType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case QueryRuleType.Pinned: - writer.WriteStringValue("pinned"); - return; + writer.WriteStringValue(MemberPinned); + break; case QueryRuleType.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(QueryRuleType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Security.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Security.g.cs index bd9dce49136..470f24f2d02 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Security.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Security.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,46 +42,58 @@ public enum AccessTokenGrantType ClientCredentials } -internal sealed class AccessTokenGrantTypeConverter : JsonConverter +internal sealed partial class AccessTokenGrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override AccessTokenGrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberKerberos = System.Text.Json.JsonEncodedText.Encode("_kerberos"); + private static readonly System.Text.Json.JsonEncodedText MemberClientCredentials = System.Text.Json.JsonEncodedText.Encode("client_credentials"); + + public override AccessTokenGrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRefreshToken)) + { + return AccessTokenGrantType.RefreshToken; + } + + if (reader.ValueTextEquals(MemberPassword)) + { + return AccessTokenGrantType.Password; + } + + if (reader.ValueTextEquals(MemberKerberos)) + { + return AccessTokenGrantType.Kerberos; + } + + if (reader.ValueTextEquals(MemberClientCredentials)) { - case "refresh_token": - return AccessTokenGrantType.RefreshToken; - case "password": - return AccessTokenGrantType.Password; - case "_kerberos": - return AccessTokenGrantType.Kerberos; - case "client_credentials": - return AccessTokenGrantType.ClientCredentials; + return AccessTokenGrantType.ClientCredentials; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AccessTokenGrantType)}'."); } - public override void Write(Utf8JsonWriter writer, AccessTokenGrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AccessTokenGrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AccessTokenGrantType.RefreshToken: - writer.WriteStringValue("refresh_token"); - return; + writer.WriteStringValue(MemberRefreshToken); + break; case AccessTokenGrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case AccessTokenGrantType.Kerberos: - writer.WriteStringValue("_kerberos"); - return; + writer.WriteStringValue(MemberKerberos); + break; case AccessTokenGrantType.ClientCredentials: - writer.WriteStringValue("client_credentials"); - return; + writer.WriteStringValue(MemberClientCredentials); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AccessTokenGrantType)}'."); } - - writer.WriteNullValue(); } } @@ -93,36 +106,40 @@ public enum ApiKeyGrantType AccessToken } -internal sealed class ApiKeyGrantTypeConverter : JsonConverter +internal sealed partial class ApiKeyGrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ApiKeyGrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + + public override ApiKeyGrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPassword)) + { + return ApiKeyGrantType.Password; + } + + if (reader.ValueTextEquals(MemberAccessToken)) { - case "password": - return ApiKeyGrantType.Password; - case "access_token": - return ApiKeyGrantType.AccessToken; + return ApiKeyGrantType.AccessToken; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ApiKeyGrantType)}'."); } - public override void Write(Utf8JsonWriter writer, ApiKeyGrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ApiKeyGrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ApiKeyGrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case ApiKeyGrantType.AccessToken: - writer.WriteStringValue("access_token"); - return; + writer.WriteStringValue(MemberAccessToken); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ApiKeyGrantType)}'."); } - - writer.WriteNullValue(); } } @@ -135,36 +152,40 @@ public enum ApiKeyType CrossCluster } -internal sealed class ApiKeyTypeConverter : JsonConverter +internal sealed partial class ApiKeyTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ApiKeyType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRest = System.Text.Json.JsonEncodedText.Encode("rest"); + private static readonly System.Text.Json.JsonEncodedText MemberCrossCluster = System.Text.Json.JsonEncodedText.Encode("cross_cluster"); + + public override ApiKeyType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRest)) { - case "rest": - return ApiKeyType.Rest; - case "cross_cluster": - return ApiKeyType.CrossCluster; + return ApiKeyType.Rest; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCrossCluster)) + { + return ApiKeyType.CrossCluster; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ApiKeyType)}'."); } - public override void Write(Utf8JsonWriter writer, ApiKeyType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ApiKeyType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ApiKeyType.Rest: - writer.WriteStringValue("rest"); - return; + writer.WriteStringValue(MemberRest); + break; case ApiKeyType.CrossCluster: - writer.WriteStringValue("cross_cluster"); - return; + writer.WriteStringValue(MemberCrossCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ApiKeyType)}'."); } - - writer.WriteNullValue(); } } @@ -172,9 +193,11 @@ public override void Write(Utf8JsonWriter writer, ApiKeyType value, JsonSerializ public readonly partial struct ClusterPrivilege : IEnumStruct { public ClusterPrivilege(string value) => Value = value; - +#if NET7_0_OR_GREATER + static ClusterPrivilege IEnumStruct.Create(string value) => value; +#else ClusterPrivilege IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static ClusterPrivilege ReadSecurity { get; } = new ClusterPrivilege("read_security"); public static ClusterPrivilege ReadPipeline { get; } = new ClusterPrivilege("read_pipeline"); @@ -236,36 +259,40 @@ public enum GrantType AccessToken } -internal sealed class GrantTypeConverter : JsonConverter +internal sealed partial class GrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + + public override GrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPassword)) { - case "password": - return GrantType.Password; - case "access_token": - return GrantType.AccessToken; + return GrantType.Password; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAccessToken)) + { + return GrantType.AccessToken; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GrantType)}'."); } - public override void Write(Utf8JsonWriter writer, GrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case GrantType.AccessToken: - writer.WriteStringValue("access_token"); - return; + writer.WriteStringValue(MemberAccessToken); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GrantType)}'."); } - - writer.WriteNullValue(); } } @@ -273,9 +300,11 @@ public override void Write(Utf8JsonWriter writer, GrantType value, JsonSerialize public readonly partial struct IndexPrivilege : IEnumStruct { public IndexPrivilege(string value) => Value = value; - +#if NET7_0_OR_GREATER + static IndexPrivilege IEnumStruct.Create(string value) => value; +#else IndexPrivilege IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static IndexPrivilege Write { get; } = new IndexPrivilege("write"); public static IndexPrivilege ViewIndexMetadata { get; } = new IndexPrivilege("view_index_metadata"); @@ -311,9 +340,11 @@ public override void Write(Utf8JsonWriter writer, GrantType value, JsonSerialize public readonly partial struct RestrictionWorkflow : IEnumStruct { public RestrictionWorkflow(string value) => Value = value; - +#if NET7_0_OR_GREATER + static RestrictionWorkflow IEnumStruct.Create(string value) => value; +#else RestrictionWorkflow IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static RestrictionWorkflow SearchApplicationQuery { get; } = new RestrictionWorkflow("search_application_query"); @@ -339,35 +370,39 @@ public enum TemplateFormat Json } -internal sealed class TemplateFormatConverter : JsonConverter +internal sealed partial class TemplateFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override TemplateFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + + public override TemplateFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) { - case "string": - return TemplateFormat.String; - case "json": - return TemplateFormat.Json; + return TemplateFormat.String; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return TemplateFormat.Json; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TemplateFormat)}'."); } - public override void Write(Utf8JsonWriter writer, TemplateFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TemplateFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TemplateFormat.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case TemplateFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TemplateFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Snapshot.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Snapshot.g.cs index 13f40008017..4dbd4f963ef 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Snapshot.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Snapshot.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -68,51 +69,67 @@ public enum ShardsStatsStage Done } -internal sealed class ShardsStatsStageConverter : JsonConverter +internal sealed partial class ShardsStatsStageConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardsStatsStage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("STARTED"); + private static readonly System.Text.Json.JsonEncodedText MemberInit = System.Text.Json.JsonEncodedText.Encode("INIT"); + private static readonly System.Text.Json.JsonEncodedText MemberFinalize = System.Text.Json.JsonEncodedText.Encode("FINALIZE"); + private static readonly System.Text.Json.JsonEncodedText MemberFailure = System.Text.Json.JsonEncodedText.Encode("FAILURE"); + private static readonly System.Text.Json.JsonEncodedText MemberDone = System.Text.Json.JsonEncodedText.Encode("DONE"); + + public override ShardsStatsStage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStarted)) { - case "STARTED": - return ShardsStatsStage.Started; - case "INIT": - return ShardsStatsStage.Init; - case "FINALIZE": - return ShardsStatsStage.Finalize; - case "FAILURE": - return ShardsStatsStage.Failure; - case "DONE": - return ShardsStatsStage.Done; + return ShardsStatsStage.Started; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberInit)) + { + return ShardsStatsStage.Init; + } + + if (reader.ValueTextEquals(MemberFinalize)) + { + return ShardsStatsStage.Finalize; + } + + if (reader.ValueTextEquals(MemberFailure)) + { + return ShardsStatsStage.Failure; + } + + if (reader.ValueTextEquals(MemberDone)) + { + return ShardsStatsStage.Done; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardsStatsStage)}'."); } - public override void Write(Utf8JsonWriter writer, ShardsStatsStage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardsStatsStage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardsStatsStage.Started: - writer.WriteStringValue("STARTED"); - return; + writer.WriteStringValue(MemberStarted); + break; case ShardsStatsStage.Init: - writer.WriteStringValue("INIT"); - return; + writer.WriteStringValue(MemberInit); + break; case ShardsStatsStage.Finalize: - writer.WriteStringValue("FINALIZE"); - return; + writer.WriteStringValue(MemberFinalize); + break; case ShardsStatsStage.Failure: - writer.WriteStringValue("FAILURE"); - return; + writer.WriteStringValue(MemberFailure); + break; case ShardsStatsStage.Done: - writer.WriteStringValue("DONE"); - return; + writer.WriteStringValue(MemberDone); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardsStatsStage)}'."); } - - writer.WriteNullValue(); } } @@ -135,60 +152,84 @@ public enum SnapshotSort Duration } -internal sealed class SnapshotSortConverter : JsonConverter +internal sealed partial class SnapshotSortConverter : System.Text.Json.Serialization.JsonConverter { - public override SnapshotSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText MemberShardCount = System.Text.Json.JsonEncodedText.Encode("shard_count"); + private static readonly System.Text.Json.JsonEncodedText MemberRepository = System.Text.Json.JsonEncodedText.Encode("repository"); + private static readonly System.Text.Json.JsonEncodedText MemberName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexCount = System.Text.Json.JsonEncodedText.Encode("index_count"); + private static readonly System.Text.Json.JsonEncodedText MemberFailedShardCount = System.Text.Json.JsonEncodedText.Encode("failed_shard_count"); + private static readonly System.Text.Json.JsonEncodedText MemberDuration = System.Text.Json.JsonEncodedText.Encode("duration"); + + public override SnapshotSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStartTime)) + { + return SnapshotSort.StartTime; + } + + if (reader.ValueTextEquals(MemberShardCount)) { - case "start_time": - return SnapshotSort.StartTime; - case "shard_count": - return SnapshotSort.ShardCount; - case "repository": - return SnapshotSort.Repository; - case "name": - return SnapshotSort.Name; - case "index_count": - return SnapshotSort.IndexCount; - case "failed_shard_count": - return SnapshotSort.FailedShardCount; - case "duration": - return SnapshotSort.Duration; + return SnapshotSort.ShardCount; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRepository)) + { + return SnapshotSort.Repository; + } + + if (reader.ValueTextEquals(MemberName)) + { + return SnapshotSort.Name; + } + + if (reader.ValueTextEquals(MemberIndexCount)) + { + return SnapshotSort.IndexCount; + } + + if (reader.ValueTextEquals(MemberFailedShardCount)) + { + return SnapshotSort.FailedShardCount; + } + + if (reader.ValueTextEquals(MemberDuration)) + { + return SnapshotSort.Duration; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnapshotSort)}'."); } - public override void Write(Utf8JsonWriter writer, SnapshotSort value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotSort value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnapshotSort.StartTime: - writer.WriteStringValue("start_time"); - return; + writer.WriteStringValue(MemberStartTime); + break; case SnapshotSort.ShardCount: - writer.WriteStringValue("shard_count"); - return; + writer.WriteStringValue(MemberShardCount); + break; case SnapshotSort.Repository: - writer.WriteStringValue("repository"); - return; + writer.WriteStringValue(MemberRepository); + break; case SnapshotSort.Name: - writer.WriteStringValue("name"); - return; + writer.WriteStringValue(MemberName); + break; case SnapshotSort.IndexCount: - writer.WriteStringValue("index_count"); - return; + writer.WriteStringValue(MemberIndexCount); + break; case SnapshotSort.FailedShardCount: - writer.WriteStringValue("failed_shard_count"); - return; + writer.WriteStringValue(MemberFailedShardCount); + break; case SnapshotSort.Duration: - writer.WriteStringValue("duration"); - return; + writer.WriteStringValue(MemberDuration); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnapshotSort)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Sql.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Sql.g.cs index 4cdbebbc92a..7d25ce373ba 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Sql.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Sql.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -47,60 +48,84 @@ public enum SqlFormat Cbor } -internal sealed class SqlFormatConverter : JsonConverter +internal sealed partial class SqlFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override SqlFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYaml = System.Text.Json.JsonEncodedText.Encode("yaml"); + private static readonly System.Text.Json.JsonEncodedText MemberTxt = System.Text.Json.JsonEncodedText.Encode("txt"); + private static readonly System.Text.Json.JsonEncodedText MemberTsv = System.Text.Json.JsonEncodedText.Encode("tsv"); + private static readonly System.Text.Json.JsonEncodedText MemberSmile = System.Text.Json.JsonEncodedText.Encode("smile"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText MemberCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText MemberCbor = System.Text.Json.JsonEncodedText.Encode("cbor"); + + public override SqlFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYaml)) + { + return SqlFormat.Yaml; + } + + if (reader.ValueTextEquals(MemberTxt)) + { + return SqlFormat.Txt; + } + + if (reader.ValueTextEquals(MemberTsv)) + { + return SqlFormat.Tsv; + } + + if (reader.ValueTextEquals(MemberSmile)) { - case "yaml": - return SqlFormat.Yaml; - case "txt": - return SqlFormat.Txt; - case "tsv": - return SqlFormat.Tsv; - case "smile": - return SqlFormat.Smile; - case "json": - return SqlFormat.Json; - case "csv": - return SqlFormat.Csv; - case "cbor": - return SqlFormat.Cbor; + return SqlFormat.Smile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return SqlFormat.Json; + } + + if (reader.ValueTextEquals(MemberCsv)) + { + return SqlFormat.Csv; + } + + if (reader.ValueTextEquals(MemberCbor)) + { + return SqlFormat.Cbor; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SqlFormat)}'."); } - public override void Write(Utf8JsonWriter writer, SqlFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SqlFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SqlFormat.Yaml: - writer.WriteStringValue("yaml"); - return; + writer.WriteStringValue(MemberYaml); + break; case SqlFormat.Txt: - writer.WriteStringValue("txt"); - return; + writer.WriteStringValue(MemberTxt); + break; case SqlFormat.Tsv: - writer.WriteStringValue("tsv"); - return; + writer.WriteStringValue(MemberTsv); + break; case SqlFormat.Smile: - writer.WriteStringValue("smile"); - return; + writer.WriteStringValue(MemberSmile); + break; case SqlFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; case SqlFormat.Csv: - writer.WriteStringValue("csv"); - return; + writer.WriteStringValue(MemberCsv); + break; case SqlFormat.Cbor: - writer.WriteStringValue("cbor"); - return; + writer.WriteStringValue(MemberCbor); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SqlFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Watcher.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Watcher.g.cs index 9a877190686..8f04bba5394 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Watcher.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Watcher.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -41,45 +42,57 @@ public enum ActionStatusOptions Failure } -internal sealed class ActionStatusOptionsConverter : JsonConverter +internal sealed partial class ActionStatusOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override ActionStatusOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText MemberSuccess = System.Text.Json.JsonEncodedText.Encode("success"); + private static readonly System.Text.Json.JsonEncodedText MemberSimulated = System.Text.Json.JsonEncodedText.Encode("simulated"); + private static readonly System.Text.Json.JsonEncodedText MemberFailure = System.Text.Json.JsonEncodedText.Encode("failure"); + + public override ActionStatusOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberThrottled)) + { + return ActionStatusOptions.Throttled; + } + + if (reader.ValueTextEquals(MemberSuccess)) { - case "throttled": - return ActionStatusOptions.Throttled; - case "success": - return ActionStatusOptions.Success; - case "simulated": - return ActionStatusOptions.Simulated; - case "failure": - return ActionStatusOptions.Failure; + return ActionStatusOptions.Success; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSimulated)) + { + return ActionStatusOptions.Simulated; + } + + if (reader.ValueTextEquals(MemberFailure)) + { + return ActionStatusOptions.Failure; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ActionStatusOptions)}'."); } - public override void Write(Utf8JsonWriter writer, ActionStatusOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ActionStatusOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ActionStatusOptions.Throttled: - writer.WriteStringValue("throttled"); - return; + writer.WriteStringValue(MemberThrottled); + break; case ActionStatusOptions.Success: - writer.WriteStringValue("success"); - return; + writer.WriteStringValue(MemberSuccess); + break; case ActionStatusOptions.Simulated: - writer.WriteStringValue("simulated"); - return; + writer.WriteStringValue(MemberSimulated); + break; case ActionStatusOptions.Failure: - writer.WriteStringValue("failure"); - return; + writer.WriteStringValue(MemberFailure); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ActionStatusOptions)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Xpack.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Xpack.g.cs index e217b5508b1..d6913a30a4b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Xpack.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Enums/Enums.Xpack.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Core; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -39,40 +40,48 @@ public enum XPackCategory Build } -internal sealed class XPackCategoryConverter : JsonConverter +internal sealed partial class XPackCategoryConverter : System.Text.Json.Serialization.JsonConverter { - public override XPackCategory Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLicense = System.Text.Json.JsonEncodedText.Encode("license"); + private static readonly System.Text.Json.JsonEncodedText MemberFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + private static readonly System.Text.Json.JsonEncodedText MemberBuild = System.Text.Json.JsonEncodedText.Encode("build"); + + public override XPackCategory Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLicense)) + { + return XPackCategory.License; + } + + if (reader.ValueTextEquals(MemberFeatures)) { - case "license": - return XPackCategory.License; - case "features": - return XPackCategory.Features; - case "build": - return XPackCategory.Build; + return XPackCategory.Features; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberBuild)) + { + return XPackCategory.Build; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(XPackCategory)}'."); } - public override void Write(Utf8JsonWriter writer, XPackCategory value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, XPackCategory value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case XPackCategory.License: - writer.WriteStringValue("license"); - return; + writer.WriteStringValue(MemberLicense); + break; case XPackCategory.Features: - writer.WriteStringValue("features"); - return; + writer.WriteStringValue(MemberFeatures); + break; case XPackCategory.Build: - writer.WriteStringValue("build"); - return; + writer.WriteStringValue(MemberBuild); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(XPackCategory)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Eql/HitsEvent.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Eql/HitsEvent.g.cs index 5614df40669..4abd24d6c98 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Eql/HitsEvent.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Eql/HitsEvent.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,10 +28,99 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Eql; +internal sealed partial class HitsEventConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override HitsEvent Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty>?> propFields = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsEvent + { + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Missing = propMissing.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsEvent value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsEventConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsEvent<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitsEventConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitsEventConverterFactory))] public sealed partial class HitsEvent { - [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary>? Fields { get; init; } /// @@ -38,7 +128,6 @@ public sealed partial class HitsEvent /// Unique identifier for the event. This ID is only unique within the index. /// /// - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } /// @@ -46,7 +135,6 @@ public sealed partial class HitsEvent /// Name of the index containing the event. /// /// - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } /// @@ -54,7 +142,6 @@ public sealed partial class HitsEvent /// Set to true for events in a timespan-constrained sequence that do not meet a given condition. /// /// - [JsonInclude, JsonPropertyName("missing")] public bool? Missing { get; init; } /// @@ -62,7 +149,5 @@ public sealed partial class HitsEvent /// Original JSON body passed for the event at index time. /// /// - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TEvent Source { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/ErrorCause.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/ErrorCause.g.cs index f5aa3c93f05..e060d3df459 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/ErrorCause.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/ErrorCause.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,72 +28,100 @@ namespace Elastic.Clients.Elasticsearch.Serverless; -internal sealed partial class ErrorCauseConverter : JsonConverter +internal sealed partial class ErrorCauseConverter : System.Text.Json.Serialization.JsonConverter { - public override ErrorCause Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropCausedBy = System.Text.Json.JsonEncodedText.Encode("caused_by"); + private static readonly System.Text.Json.JsonEncodedText PropReason = System.Text.Json.JsonEncodedText.Encode("reason"); + private static readonly System.Text.Json.JsonEncodedText PropRootCause = System.Text.Json.JsonEncodedText.Encode("root_cause"); + private static readonly System.Text.Json.JsonEncodedText PropStackTrace = System.Text.Json.JsonEncodedText.Encode("stack_trace"); + private static readonly System.Text.Json.JsonEncodedText PropSuppressed = System.Text.Json.JsonEncodedText.Encode("suppressed"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ErrorCause Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - Elastic.Clients.Elasticsearch.Serverless.ErrorCause? causedBy = default; - string? reason = default; - IReadOnlyCollection? rootCause = default; - string? stackTrace = default; - IReadOnlyCollection? suppressed = default; - string type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonProperty propCausedBy = default; + LocalJsonProperty propReason = default; + LocalJsonProperty?> propRootCause = default; + LocalJsonProperty propStackTrace = default; + LocalJsonProperty?> propSuppressed = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propCausedBy.TryRead(ref reader, options, PropCausedBy)) { - var property = reader.GetString(); - if (property == "caused_by") - { - causedBy = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "reason") - { - reason = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "root_cause") - { - rootCause = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stack_trace") - { - stackTrace = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suppressed") - { - suppressed = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propReason.TryRead(ref reader, options, PropReason)) + { + continue; + } + + if (propRootCause.TryRead(ref reader, options, PropRootCause)) + { + continue; + } + + if (propStackTrace.TryRead(ref reader, options, PropStackTrace)) + { + continue; + } + + if (propSuppressed.TryRead(ref reader, options, PropSuppressed)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propMetadata[key] = value; } - return new ErrorCause { CausedBy = causedBy, Metadata = additionalProperties, Reason = reason, RootCause = rootCause, StackTrace = stackTrace, Suppressed = suppressed, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ErrorCause + { + Metadata = propMetadata +, + CausedBy = propCausedBy.Value +, + Reason = propReason.Value +, + RootCause = propRootCause.Value +, + StackTrace = propStackTrace.Value +, + Suppressed = propSuppressed.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, ErrorCause value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ErrorCause value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ErrorCause' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropCausedBy, value.CausedBy); + writer.WriteProperty(options, PropReason, value.Reason); + writer.WriteProperty(options, PropRootCause, value.RootCause); + writer.WriteProperty(options, PropStackTrace, value.StackTrace); + writer.WriteProperty(options, PropSuppressed, value.Suppressed); + writer.WriteProperty(options, PropType, value.Type); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FieldSort.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FieldSort.g.cs index 430fc042c4c..93e97ccb97f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FieldSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FieldSort.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,21 +28,114 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class FieldSortConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText PropNumericType = System.Text.Json.JsonEncodedText.Encode("numeric_type"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropUnmappedType = System.Text.Json.JsonEncodedText.Encode("unmapped_type"); + + public override FieldSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new FieldSort { Order = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFormat = default; + LocalJsonProperty propMissing = default; + LocalJsonProperty propMode = default; + LocalJsonProperty propNested = default; + LocalJsonProperty propNumericType = default; + LocalJsonProperty propOrder = default; + LocalJsonProperty propUnmappedType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } + + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } + + if (propNumericType.TryRead(ref reader, options, PropNumericType)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } + + if (propUnmappedType.TryRead(ref reader, options, PropUnmappedType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldSort + { + Format = propFormat.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value +, + Nested = propNested.Value +, + NumericType = propNumericType.Value +, + Order = propOrder.Value +, + UnmappedType = propUnmappedType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropNumericType, value.NumericType); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropUnmappedType, value.UnmappedType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldSortConverter))] public sealed partial class FieldSort { - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.Serverless.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] public Elastic.Clients.Elasticsearch.Serverless.SortMode? Mode { get; set; } - [JsonInclude, JsonPropertyName("nested")] public Elastic.Clients.Elasticsearch.Serverless.NestedSortValue? Nested { get; set; } - [JsonInclude, JsonPropertyName("numeric_type")] public Elastic.Clients.Elasticsearch.Serverless.FieldSortNumericType? NumericType { get; set; } - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.Serverless.SortOrder? Order { get; set; } - [JsonInclude, JsonPropertyName("unmapped_type")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.FieldType? UnmappedType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FielddataStats.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FielddataStats.g.cs index 56985a0b49d..4fefb32c52c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FielddataStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/FielddataStats.g.cs @@ -32,7 +32,6 @@ public sealed partial class FielddataStats [JsonInclude, JsonPropertyName("evictions")] public long? Evictions { get; init; } [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.FieldMemoryUsage))] public IReadOnlyDictionary? Fields { get; init; } [JsonInclude, JsonPropertyName("memory_size")] public Elastic.Clients.Elasticsearch.Serverless.ByteSize? MemorySize { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/GeoDistanceSort.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/GeoDistanceSort.g.cs index a691a7efc98..be18de4a947 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/GeoDistanceSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/GeoDistanceSort.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,114 +28,95 @@ namespace Elastic.Clients.Elasticsearch.Serverless; -internal sealed partial class GeoDistanceSortConverter : JsonConverter +internal sealed partial class GeoDistanceSortConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropDistanceType = System.Text.Json.JsonEncodedText.Encode("distance_type"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropUnit = System.Text.Json.JsonEncodedText.Encode("unit"); + + public override GeoDistanceSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDistanceSort(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty> propLocation = default; + LocalJsonProperty propDistanceType = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propMode = default; + LocalJsonProperty propNested = default; + LocalJsonProperty propOrder = default; + LocalJsonProperty propUnit = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDistanceType.TryRead(ref reader, options, PropDistanceType)) { - var property = reader.GetString(); - if (property == "distance_type") - { - variant.DistanceType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mode") - { - variant.Mode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "nested") - { - variant.Nested = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "order") - { - variant.Order = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "unit") - { - variant.Unit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Location = JsonSerializer.Deserialize>(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoDistanceSort value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Location is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Location, options); - } - - if (value.DistanceType is not null) - { - writer.WritePropertyName("distance_type"); - JsonSerializer.Serialize(writer, value.DistanceType, options); - } + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } - if (value.Mode is not null) - { - writer.WritePropertyName("mode"); - JsonSerializer.Serialize(writer, value.Mode, options); - } + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } - if (value.Nested is not null) - { - writer.WritePropertyName("nested"); - JsonSerializer.Serialize(writer, value.Nested, options); - } + if (propUnit.TryRead(ref reader, options, PropUnit)) + { + continue; + } - if (value.Order is not null) - { - writer.WritePropertyName("order"); - JsonSerializer.Serialize(writer, value.Order, options); + propField.Initialized = propLocation.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propLocation.Value, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.GeoLocation>)); } - if (value.Unit is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDistanceSort { - writer.WritePropertyName("unit"); - JsonSerializer.Serialize(writer, value.Unit, options); - } + Field = propField.Value +, + Location = propLocation.Value +, + DistanceType = propDistanceType.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + Mode = propMode.Value +, + Nested = propNested.Value +, + Order = propOrder.Value +, + Unit = propUnit.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDistanceType, value.DistanceType); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropUnit, value.Unit); + writer.WriteProperty(options, value.Field, value.Location, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.GeoLocation>)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/AddAction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/AddAction.g.cs index b7b1346d94b..4079f861104 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/AddAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/AddAction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,140 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class AddActionConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexRouting = System.Text.Json.JsonEncodedText.Encode("index_routing"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIsHidden = System.Text.Json.JsonEncodedText.Encode("is_hidden"); + private static readonly System.Text.Json.JsonEncodedText PropIsWriteIndex = System.Text.Json.JsonEncodedText.Encode("is_write_index"); + private static readonly System.Text.Json.JsonEncodedText PropMustExist = System.Text.Json.JsonEncodedText.Encode("must_exist"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSearchRouting = System.Text.Json.JsonEncodedText.Encode("search_routing"); + + public override AddAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAlias = default; + LocalJsonProperty?> propAliases = default; + LocalJsonProperty propFilter = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexRouting = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propIsHidden = default; + LocalJsonProperty propIsWriteIndex = default; + LocalJsonProperty propMustExist = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSearchRouting = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryRead(ref reader, options, PropAlias)) + { + continue; + } + + if (propAliases.TryRead(ref reader, options, PropAliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexAlias>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexRouting.TryRead(ref reader, options, PropIndexRouting)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIsHidden.TryRead(ref reader, options, PropIsHidden)) + { + continue; + } + + if (propIsWriteIndex.TryRead(ref reader, options, PropIsWriteIndex)) + { + continue; + } + + if (propMustExist.TryRead(ref reader, options, PropMustExist)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSearchRouting.TryRead(ref reader, options, PropSearchRouting)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AddAction + { + Alias = propAlias.Value +, + Aliases = propAliases.Value +, + Filter = propFilter.Value +, + Index = propIndex.Value +, + IndexRouting = propIndexRouting.Value +, + Indices = propIndices.Value +, + IsHidden = propIsHidden.Value +, + IsWriteIndex = propIsWriteIndex.Value +, + MustExist = propMustExist.Value +, + Routing = propRouting.Value +, + SearchRouting = propSearchRouting.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AddAction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlias, value.Alias); + writer.WriteProperty(options, PropAliases, value.Aliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexAlias>)); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexRouting, value.IndexRouting); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIsHidden, value.IsHidden); + writer.WriteProperty(options, PropIsWriteIndex, value.IsWriteIndex); + writer.WriteProperty(options, PropMustExist, value.MustExist); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSearchRouting, value.SearchRouting); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AddActionConverter))] public sealed partial class AddAction { /// @@ -35,7 +170,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.Serverless.IndexAlias? Alias { get; set; } /// @@ -44,8 +178,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -53,7 +185,6 @@ public sealed partial class AddAction /// Query used to limit documents the alias can access. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Filter { get; set; } /// @@ -62,7 +193,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; } /// @@ -72,7 +202,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("index_routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? IndexRouting { get; set; } /// @@ -81,7 +210,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } /// @@ -89,7 +217,6 @@ public sealed partial class AddAction /// If true, the alias is hidden. /// /// - [JsonInclude, JsonPropertyName("is_hidden")] public bool? IsHidden { get; set; } /// @@ -97,7 +224,6 @@ public sealed partial class AddAction /// If true, sets the write index or data stream for the alias. /// /// - [JsonInclude, JsonPropertyName("is_write_index")] public bool? IsWriteIndex { get; set; } /// @@ -105,7 +231,6 @@ public sealed partial class AddAction /// If true, the alias must exist to perform the action. /// /// - [JsonInclude, JsonPropertyName("must_exist")] public bool? MustExist { get; set; } /// @@ -114,7 +239,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } /// @@ -124,7 +248,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("search_routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? SearchRouting { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexUpdateAliasesAction(AddAction addAction) => Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexUpdateAliasesAction.Add(addAction); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs index 9d6ab4edf40..d92e87abe52 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,93 +28,130 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; -internal sealed partial class ExplainAnalyzeTokenConverter : JsonConverter +internal sealed partial class ExplainAnalyzeTokenConverter : System.Text.Json.Serialization.JsonConverter { - public override ExplainAnalyzeToken Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropBytes = System.Text.Json.JsonEncodedText.Encode("bytes"); + private static readonly System.Text.Json.JsonEncodedText PropEndOffset = System.Text.Json.JsonEncodedText.Encode("end_offset"); + private static readonly System.Text.Json.JsonEncodedText PropKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText PropPosition = System.Text.Json.JsonEncodedText.Encode("position"); + private static readonly System.Text.Json.JsonEncodedText PropPositionlength = System.Text.Json.JsonEncodedText.Encode("positionLength"); + private static readonly System.Text.Json.JsonEncodedText PropStartOffset = System.Text.Json.JsonEncodedText.Encode("start_offset"); + private static readonly System.Text.Json.JsonEncodedText PropTermfrequency = System.Text.Json.JsonEncodedText.Encode("termFrequency"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ExplainAnalyzeToken Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - string bytes = default; - long endOffset = default; - bool? keyword = default; - long position = default; - long positionlength = default; - long startOffset = default; - long termfrequency = default; - string token = default; - string type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAttributes = default; + LocalJsonProperty propBytes = default; + LocalJsonProperty propEndOffset = default; + LocalJsonProperty propKeyword = default; + LocalJsonProperty propPosition = default; + LocalJsonProperty propPositionlength = default; + LocalJsonProperty propStartOffset = default; + LocalJsonProperty propTermfrequency = default; + LocalJsonProperty propToken = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBytes.TryRead(ref reader, options, PropBytes)) { - var property = reader.GetString(); - if (property == "bytes") - { - bytes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "end_offset") - { - endOffset = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "keyword") - { - keyword = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "position") - { - position = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "positionLength") - { - positionlength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "start_offset") - { - startOffset = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "termFrequency") - { - termfrequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "token") - { - token = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propEndOffset.TryRead(ref reader, options, PropEndOffset)) + { + continue; + } + + if (propKeyword.TryRead(ref reader, options, PropKeyword)) + { + continue; + } + + if (propPosition.TryRead(ref reader, options, PropPosition)) + { + continue; + } + + if (propPositionlength.TryRead(ref reader, options, PropPositionlength)) + { + continue; + } + + if (propStartOffset.TryRead(ref reader, options, PropStartOffset)) + { + continue; + } + + if (propTermfrequency.TryRead(ref reader, options, PropTermfrequency)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + propAttributes ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propAttributes[key] = value; } - return new ExplainAnalyzeToken { Attributes = additionalProperties, Bytes = bytes, EndOffset = endOffset, Keyword = keyword, Position = position, Positionlength = positionlength, StartOffset = startOffset, Termfrequency = termfrequency, Token = token, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainAnalyzeToken + { + Attributes = propAttributes +, + Bytes = propBytes.Value +, + EndOffset = propEndOffset.Value +, + Keyword = propKeyword.Value +, + Position = propPosition.Value +, + Positionlength = propPositionlength.Value +, + StartOffset = propStartOffset.Value +, + Termfrequency = propTermfrequency.Value +, + Token = propToken.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, ExplainAnalyzeToken value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainAnalyzeToken value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ExplainAnalyzeToken' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBytes, value.Bytes); + writer.WriteProperty(options, PropEndOffset, value.EndOffset); + writer.WriteProperty(options, PropKeyword, value.Keyword); + writer.WriteProperty(options, PropPosition, value.Position); + writer.WriteProperty(options, PropPositionlength, value.Positionlength); + writer.WriteProperty(options, PropStartOffset, value.StartOffset); + writer.WriteProperty(options, PropTermfrequency, value.Termfrequency); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteProperty(options, PropType, value.Type); + if (value.Attributes is not null) + { + foreach (var item in value.Attributes) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs index 1ae8a45a42f..b207890b479 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal IndexModifyDataStreamAction(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IndexModifyDataStreamAction() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IndexModifyDataStreamAction AddBackingIndex(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("add_backing_index", indexAndDataStreamAction); public static IndexModifyDataStreamAction RemoveBackingIndex(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("remove_backing_index", indexAndDataStreamAction); @@ -62,67 +67,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IndexModifyDataStreamActionConverter : JsonConverter +internal sealed partial class IndexModifyDataStreamActionConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexModifyDataStreamAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantAddBackingIndex = System.Text.Json.JsonEncodedText.Encode("add_backing_index"); + private static readonly System.Text.Json.JsonEncodedText VariantRemoveBackingIndex = System.Text.Json.JsonEncodedText.Encode("remove_backing_index"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override IndexModifyDataStreamAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAddBackingIndex)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add_backing_index") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAddBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove_backing_index") + if (reader.ValueTextEquals(VariantRemoveBackingIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IndexModifyDataStreamAction' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IndexModifyDataStreamAction(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexModifyDataStreamAction { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IndexModifyDataStreamAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexModifyDataStreamAction value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "add_backing_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - case "remove_backing_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - } + case "": + break; + case "add_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction?)value.Variant); + break; + case "remove_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexAndDataStreamAction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IndexModifyDataStreamAction)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs index 3aedc9a4378..b0aea168367 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,19 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class IndexSegmentSortConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + + public override IndexSegmentSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty?> propMissing = default; + LocalJsonProperty?> propMode = default; + LocalJsonProperty?> propOrder = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>))) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>))) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexSegmentSort + { + Field = propField.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value +, + Order = propOrder.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexSegmentSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMissing, value.Missing, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing>)); + writer.WriteProperty(options, PropMode, value.Mode, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode>)); + writer.WriteProperty(options, PropOrder, value.Order, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexSegmentSortConverter))] public sealed partial class IndexSegmentSort { - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Field { get; set; } - [JsonInclude, JsonPropertyName("missing")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMissing))] public ICollection? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortMode))] public ICollection? Mode { get; set; } - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SegmentSortOrder))] public ICollection? Order { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSettings.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSettings.g.cs index ef149859971..39fcfb8f01a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSettings.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexSettings.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,711 +28,597 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; -internal sealed partial class IndexSettingsConverter : JsonConverter +internal sealed partial class IndexSettingsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexSettings Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new IndexSettings(); - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropOtherSettings = System.Text.Json.JsonEncodedText.Encode("other_settings"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyze = System.Text.Json.JsonEncodedText.Encode("analyze"); + private static readonly System.Text.Json.JsonEncodedText PropAutoExpandReplicas = System.Text.Json.JsonEncodedText.Encode("auto_expand_replicas"); + private static readonly System.Text.Json.JsonEncodedText PropBlocks = System.Text.Json.JsonEncodedText.Encode("blocks"); + private static readonly System.Text.Json.JsonEncodedText PropCheckOnStartup = System.Text.Json.JsonEncodedText.Encode("check_on_startup"); + private static readonly System.Text.Json.JsonEncodedText PropCodec = System.Text.Json.JsonEncodedText.Encode("codec"); + private static readonly System.Text.Json.JsonEncodedText PropCreationDate = System.Text.Json.JsonEncodedText.Encode("creation_date"); + private static readonly System.Text.Json.JsonEncodedText PropCreationDateString = System.Text.Json.JsonEncodedText.Encode("creation_date_string"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultPipeline = System.Text.Json.JsonEncodedText.Encode("default_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropFinalPipeline = System.Text.Json.JsonEncodedText.Encode("final_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGcDeletes = System.Text.Json.JsonEncodedText.Encode("gc_deletes"); + private static readonly System.Text.Json.JsonEncodedText PropHidden = System.Text.Json.JsonEncodedText.Encode("hidden"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingPressure = System.Text.Json.JsonEncodedText.Encode("indexing_pressure"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingSlowlog = System.Text.Json.JsonEncodedText.Encode("indexing.slowlog"); + private static readonly System.Text.Json.JsonEncodedText PropLifecycle = System.Text.Json.JsonEncodedText.Encode("lifecycle"); + private static readonly System.Text.Json.JsonEncodedText PropLoadFixedBitsetFiltersEagerly = System.Text.Json.JsonEncodedText.Encode("load_fixed_bitset_filters_eagerly"); + private static readonly System.Text.Json.JsonEncodedText PropMapping = System.Text.Json.JsonEncodedText.Encode("mapping"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDocvalueFieldsSearch = System.Text.Json.JsonEncodedText.Encode("max_docvalue_fields_search"); + private static readonly System.Text.Json.JsonEncodedText PropMaxInnerResultWindow = System.Text.Json.JsonEncodedText.Encode("max_inner_result_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNgramDiff = System.Text.Json.JsonEncodedText.Encode("max_ngram_diff"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRefreshListeners = System.Text.Json.JsonEncodedText.Encode("max_refresh_listeners"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRegexLength = System.Text.Json.JsonEncodedText.Encode("max_regex_length"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRescoreWindow = System.Text.Json.JsonEncodedText.Encode("max_rescore_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxResultWindow = System.Text.Json.JsonEncodedText.Encode("max_result_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScriptFields = System.Text.Json.JsonEncodedText.Encode("max_script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropMaxShingleDiff = System.Text.Json.JsonEncodedText.Encode("max_shingle_diff"); + private static readonly System.Text.Json.JsonEncodedText PropMaxSlicesPerScroll = System.Text.Json.JsonEncodedText.Encode("max_slices_per_scroll"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTermsCount = System.Text.Json.JsonEncodedText.Encode("max_terms_count"); + private static readonly System.Text.Json.JsonEncodedText PropMerge = System.Text.Json.JsonEncodedText.Encode("merge"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfReplicas = System.Text.Json.JsonEncodedText.Encode("number_of_replicas"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfRoutingShards = System.Text.Json.JsonEncodedText.Encode("number_of_routing_shards"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfShards = System.Text.Json.JsonEncodedText.Encode("number_of_shards"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropProvidedName = System.Text.Json.JsonEncodedText.Encode("provided_name"); + private static readonly System.Text.Json.JsonEncodedText PropQueries = System.Text.Json.JsonEncodedText.Encode("queries"); + private static readonly System.Text.Json.JsonEncodedText PropQueryString = System.Text.Json.JsonEncodedText.Encode("query_string"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshInterval = System.Text.Json.JsonEncodedText.Encode("refresh_interval"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropRoutingPartitionSize = System.Text.Json.JsonEncodedText.Encode("routing_partition_size"); + private static readonly System.Text.Json.JsonEncodedText PropRoutingPath = System.Text.Json.JsonEncodedText.Encode("routing_path"); + private static readonly System.Text.Json.JsonEncodedText PropSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropSoftDeletes = System.Text.Json.JsonEncodedText.Encode("soft_deletes"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeries = System.Text.Json.JsonEncodedText.Encode("time_series"); + private static readonly System.Text.Json.JsonEncodedText PropTopMetricsMaxSize = System.Text.Json.JsonEncodedText.Encode("top_metrics_max_size"); + private static readonly System.Text.Json.JsonEncodedText PropTranslog = System.Text.Json.JsonEncodedText.Encode("translog"); + private static readonly System.Text.Json.JsonEncodedText PropUuid = System.Text.Json.JsonEncodedText.Encode("uuid"); + private static readonly System.Text.Json.JsonEncodedText PropVerifiedBeforeClose = System.Text.Json.JsonEncodedText.Encode("verified_before_close"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override IndexSettings Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propOtherSettings = default; + LocalJsonProperty propAnalysis = default; + LocalJsonProperty propAnalyze = default; + LocalJsonProperty propAutoExpandReplicas = default; + LocalJsonProperty propBlocks = default; + LocalJsonProperty propCheckOnStartup = default; + LocalJsonProperty propCodec = default; + LocalJsonProperty propCreationDate = default; + LocalJsonProperty propCreationDateString = default; + LocalJsonProperty propDefaultPipeline = default; + LocalJsonProperty propFinalPipeline = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propGcDeletes = default; + LocalJsonProperty propHidden = default; + LocalJsonProperty propHighlight = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexingPressure = default; + LocalJsonProperty propIndexingSlowlog = default; + LocalJsonProperty propLifecycle = default; + LocalJsonProperty propLoadFixedBitsetFiltersEagerly = default; + LocalJsonProperty propMapping = default; + LocalJsonProperty propMaxDocvalueFieldsSearch = default; + LocalJsonProperty propMaxInnerResultWindow = default; + LocalJsonProperty propMaxNgramDiff = default; + LocalJsonProperty propMaxRefreshListeners = default; + LocalJsonProperty propMaxRegexLength = default; + LocalJsonProperty propMaxRescoreWindow = default; + LocalJsonProperty propMaxResultWindow = default; + LocalJsonProperty propMaxScriptFields = default; + LocalJsonProperty propMaxShingleDiff = default; + LocalJsonProperty propMaxSlicesPerScroll = default; + LocalJsonProperty propMaxTermsCount = default; + LocalJsonProperty propMerge = default; + LocalJsonProperty propMode = default; + LocalJsonProperty propNumberOfReplicas = default; + LocalJsonProperty propNumberOfRoutingShards = default; + LocalJsonProperty propNumberOfShards = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propProvidedName = default; + LocalJsonProperty propQueries = default; + LocalJsonProperty propQueryString = default; + LocalJsonProperty propRefreshInterval = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propRoutingPartitionSize = default; + LocalJsonProperty?> propRoutingPath = default; + LocalJsonProperty propSearch = default; + LocalJsonProperty propSettings = default; + LocalJsonProperty propSimilarity = default; + LocalJsonProperty propSoftDeletes = default; + LocalJsonProperty propSort = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propTimeSeries = default; + LocalJsonProperty propTopMetricsMaxSize = default; + LocalJsonProperty propTranslog = default; + LocalJsonProperty propUuid = default; + LocalJsonProperty propVerifiedBeforeClose = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) { - var property = reader.GetString(); - if (property == "analysis") - { - variant.Analysis = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "analyze") - { - variant.Analyze = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "auto_expand_replicas") - { - variant.AutoExpandReplicas = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "blocks") - { - variant.Blocks = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "check_on_startup") - { - variant.CheckOnStartup = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "codec") - { - variant.Codec = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "creation_date") - { - variant.CreationDate = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "creation_date_string") - { - variant.CreationDateString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "default_pipeline") - { - variant.DefaultPipeline = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "final_pipeline") - { - variant.FinalPipeline = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gc_deletes") - { - variant.GcDeletes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "hidden") - { - variant.Hidden = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "index") - { - variant.Index = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexing_pressure") - { - variant.IndexingPressure = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexing.slowlog") - { - variant.IndexingSlowlog = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lifecycle") - { - variant.Lifecycle = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "load_fixed_bitset_filters_eagerly") - { - variant.LoadFixedBitsetFiltersEagerly = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mapping") - { - variant.Mapping = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_docvalue_fields_search") - { - variant.MaxDocvalueFieldsSearch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_inner_result_window") - { - variant.MaxInnerResultWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_ngram_diff") - { - variant.MaxNgramDiff = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_refresh_listeners") - { - variant.MaxRefreshListeners = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_regex_length") - { - variant.MaxRegexLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_rescore_window") - { - variant.MaxRescoreWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_result_window") - { - variant.MaxResultWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_script_fields") - { - variant.MaxScriptFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_shingle_diff") - { - variant.MaxShingleDiff = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_slices_per_scroll") - { - variant.MaxSlicesPerScroll = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_terms_count") - { - variant.MaxTermsCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "merge") - { - variant.Merge = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mode") - { - variant.Mode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_replicas") - { - variant.NumberOfReplicas = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_routing_shards") - { - variant.NumberOfRoutingShards = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_shards") - { - variant.NumberOfShards = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "priority") - { - variant.Priority = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "provided_name") - { - variant.ProvidedName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "queries") - { - variant.Queries = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_string") - { - variant.QueryString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "refresh_interval") - { - variant.RefreshInterval = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing") - { - variant.Routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing_partition_size") - { - variant.RoutingPartitionSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing_path") - { - variant.RoutingPath = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "search") - { - variant.Search = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "settings") - { - variant.Settings = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "similarity") - { - variant.Similarity = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_deletes") - { - variant.SoftDeletes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "store") - { - variant.Store = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_series") - { - variant.TimeSeries = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "top_metrics_max_size") - { - variant.TopMetricsMaxSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "translog") - { - variant.Translog = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "uuid") - { - variant.Uuid = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "verified_before_close") - { - variant.VerifiedBeforeClose = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } - } - - variant.OtherSettings = additionalProperties; - return variant; - } - public override void Write(Utf8JsonWriter writer, IndexSettings value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.OtherSettings is not null) - { - foreach (var additionalProperty in value.OtherSettings) + if (propAnalyze.TryRead(ref reader, options, PropAnalyze)) { - writer.WritePropertyName(additionalProperty.Key); - JsonSerializer.Serialize(writer, additionalProperty.Value, options); + continue; } - } - if (value.Analysis is not null) - { - writer.WritePropertyName("analysis"); - JsonSerializer.Serialize(writer, value.Analysis, options); - } - - if (value.Analyze is not null) - { - writer.WritePropertyName("analyze"); - JsonSerializer.Serialize(writer, value.Analyze, options); - } + if (propAutoExpandReplicas.TryRead(ref reader, options, PropAutoExpandReplicas)) + { + continue; + } - if (!string.IsNullOrEmpty(value.AutoExpandReplicas)) - { - writer.WritePropertyName("auto_expand_replicas"); - writer.WriteStringValue(value.AutoExpandReplicas); - } + if (propBlocks.TryRead(ref reader, options, PropBlocks)) + { + continue; + } - if (value.Blocks is not null) - { - writer.WritePropertyName("blocks"); - JsonSerializer.Serialize(writer, value.Blocks, options); - } + if (propCheckOnStartup.TryRead(ref reader, options, PropCheckOnStartup)) + { + continue; + } - if (value.CheckOnStartup is not null) - { - writer.WritePropertyName("check_on_startup"); - JsonSerializer.Serialize(writer, value.CheckOnStartup, options); - } + if (propCodec.TryRead(ref reader, options, PropCodec)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Codec)) - { - writer.WritePropertyName("codec"); - writer.WriteStringValue(value.Codec); - } + if (propCreationDate.TryRead(ref reader, options, PropCreationDate)) + { + continue; + } - if (value.CreationDate.HasValue) - { - writer.WritePropertyName("creation_date"); - writer.WriteNumberValue(value.CreationDate.Value); - } + if (propCreationDateString.TryRead(ref reader, options, PropCreationDateString)) + { + continue; + } - if (value.CreationDateString is not null) - { - writer.WritePropertyName("creation_date_string"); - JsonSerializer.Serialize(writer, value.CreationDateString, options); - } + if (propDefaultPipeline.TryRead(ref reader, options, PropDefaultPipeline)) + { + continue; + } - if (!string.IsNullOrEmpty(value.DefaultPipeline)) - { - writer.WritePropertyName("default_pipeline"); - writer.WriteStringValue(value.DefaultPipeline); - } + if (propFinalPipeline.TryRead(ref reader, options, PropFinalPipeline)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FinalPipeline)) - { - writer.WritePropertyName("final_pipeline"); - writer.WriteStringValue(value.FinalPipeline); - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - if (value.Format is not null) - { - writer.WritePropertyName("format"); - JsonSerializer.Serialize(writer, value.Format, options); - } + if (propGcDeletes.TryRead(ref reader, options, PropGcDeletes)) + { + continue; + } - if (value.GcDeletes is not null) - { - writer.WritePropertyName("gc_deletes"); - JsonSerializer.Serialize(writer, value.GcDeletes, options); - } + if (propHidden.TryRead(ref reader, options, PropHidden)) + { + continue; + } - if (value.Hidden is not null) - { - writer.WritePropertyName("hidden"); - JsonSerializer.Serialize(writer, value.Hidden, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } - if (value.Index is not null) - { - writer.WritePropertyName("index"); - JsonSerializer.Serialize(writer, value.Index, options); - } + if (propIndexingPressure.TryRead(ref reader, options, PropIndexingPressure)) + { + continue; + } - if (value.IndexingPressure is not null) - { - writer.WritePropertyName("indexing_pressure"); - JsonSerializer.Serialize(writer, value.IndexingPressure, options); - } + if (propIndexingSlowlog.TryRead(ref reader, options, PropIndexingSlowlog)) + { + continue; + } - if (value.IndexingSlowlog is not null) - { - writer.WritePropertyName("indexing.slowlog"); - JsonSerializer.Serialize(writer, value.IndexingSlowlog, options); - } + if (propLifecycle.TryRead(ref reader, options, PropLifecycle)) + { + continue; + } - if (value.Lifecycle is not null) - { - writer.WritePropertyName("lifecycle"); - JsonSerializer.Serialize(writer, value.Lifecycle, options); - } + if (propLoadFixedBitsetFiltersEagerly.TryRead(ref reader, options, PropLoadFixedBitsetFiltersEagerly)) + { + continue; + } - if (value.LoadFixedBitsetFiltersEagerly.HasValue) - { - writer.WritePropertyName("load_fixed_bitset_filters_eagerly"); - writer.WriteBooleanValue(value.LoadFixedBitsetFiltersEagerly.Value); - } + if (propMapping.TryRead(ref reader, options, PropMapping)) + { + continue; + } - if (value.Mapping is not null) - { - writer.WritePropertyName("mapping"); - JsonSerializer.Serialize(writer, value.Mapping, options); - } + if (propMaxDocvalueFieldsSearch.TryRead(ref reader, options, PropMaxDocvalueFieldsSearch)) + { + continue; + } - if (value.MaxDocvalueFieldsSearch.HasValue) - { - writer.WritePropertyName("max_docvalue_fields_search"); - writer.WriteNumberValue(value.MaxDocvalueFieldsSearch.Value); - } + if (propMaxInnerResultWindow.TryRead(ref reader, options, PropMaxInnerResultWindow)) + { + continue; + } - if (value.MaxInnerResultWindow.HasValue) - { - writer.WritePropertyName("max_inner_result_window"); - writer.WriteNumberValue(value.MaxInnerResultWindow.Value); - } + if (propMaxNgramDiff.TryRead(ref reader, options, PropMaxNgramDiff)) + { + continue; + } - if (value.MaxNgramDiff.HasValue) - { - writer.WritePropertyName("max_ngram_diff"); - writer.WriteNumberValue(value.MaxNgramDiff.Value); - } + if (propMaxRefreshListeners.TryRead(ref reader, options, PropMaxRefreshListeners)) + { + continue; + } - if (value.MaxRefreshListeners.HasValue) - { - writer.WritePropertyName("max_refresh_listeners"); - writer.WriteNumberValue(value.MaxRefreshListeners.Value); - } + if (propMaxRegexLength.TryRead(ref reader, options, PropMaxRegexLength)) + { + continue; + } - if (value.MaxRegexLength.HasValue) - { - writer.WritePropertyName("max_regex_length"); - writer.WriteNumberValue(value.MaxRegexLength.Value); - } + if (propMaxRescoreWindow.TryRead(ref reader, options, PropMaxRescoreWindow)) + { + continue; + } - if (value.MaxRescoreWindow.HasValue) - { - writer.WritePropertyName("max_rescore_window"); - writer.WriteNumberValue(value.MaxRescoreWindow.Value); - } + if (propMaxResultWindow.TryRead(ref reader, options, PropMaxResultWindow)) + { + continue; + } - if (value.MaxResultWindow.HasValue) - { - writer.WritePropertyName("max_result_window"); - writer.WriteNumberValue(value.MaxResultWindow.Value); - } + if (propMaxScriptFields.TryRead(ref reader, options, PropMaxScriptFields)) + { + continue; + } - if (value.MaxScriptFields.HasValue) - { - writer.WritePropertyName("max_script_fields"); - writer.WriteNumberValue(value.MaxScriptFields.Value); - } + if (propMaxShingleDiff.TryRead(ref reader, options, PropMaxShingleDiff)) + { + continue; + } - if (value.MaxShingleDiff.HasValue) - { - writer.WritePropertyName("max_shingle_diff"); - writer.WriteNumberValue(value.MaxShingleDiff.Value); - } + if (propMaxSlicesPerScroll.TryRead(ref reader, options, PropMaxSlicesPerScroll)) + { + continue; + } - if (value.MaxSlicesPerScroll.HasValue) - { - writer.WritePropertyName("max_slices_per_scroll"); - writer.WriteNumberValue(value.MaxSlicesPerScroll.Value); - } + if (propMaxTermsCount.TryRead(ref reader, options, PropMaxTermsCount)) + { + continue; + } - if (value.MaxTermsCount.HasValue) - { - writer.WritePropertyName("max_terms_count"); - writer.WriteNumberValue(value.MaxTermsCount.Value); - } + if (propMerge.TryRead(ref reader, options, PropMerge)) + { + continue; + } - if (value.Merge is not null) - { - writer.WritePropertyName("merge"); - JsonSerializer.Serialize(writer, value.Merge, options); - } + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Mode)) - { - writer.WritePropertyName("mode"); - writer.WriteStringValue(value.Mode); - } + if (propNumberOfReplicas.TryRead(ref reader, options, PropNumberOfReplicas)) + { + continue; + } - if (value.NumberOfReplicas is not null) - { - writer.WritePropertyName("number_of_replicas"); - JsonSerializer.Serialize(writer, value.NumberOfReplicas, options); - } + if (propNumberOfRoutingShards.TryRead(ref reader, options, PropNumberOfRoutingShards)) + { + continue; + } - if (value.NumberOfRoutingShards.HasValue) - { - writer.WritePropertyName("number_of_routing_shards"); - writer.WriteNumberValue(value.NumberOfRoutingShards.Value); - } + if (propNumberOfShards.TryRead(ref reader, options, PropNumberOfShards)) + { + continue; + } - if (value.NumberOfShards is not null) - { - writer.WritePropertyName("number_of_shards"); - JsonSerializer.Serialize(writer, value.NumberOfShards, options); - } + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } - if (value.Priority is not null) - { - writer.WritePropertyName("priority"); - JsonSerializer.Serialize(writer, value.Priority, options); - } + if (propProvidedName.TryRead(ref reader, options, PropProvidedName)) + { + continue; + } - if (value.ProvidedName is not null) - { - writer.WritePropertyName("provided_name"); - JsonSerializer.Serialize(writer, value.ProvidedName, options); - } + if (propQueries.TryRead(ref reader, options, PropQueries)) + { + continue; + } - if (value.Queries is not null) - { - writer.WritePropertyName("queries"); - JsonSerializer.Serialize(writer, value.Queries, options); - } + if (propQueryString.TryRead(ref reader, options, PropQueryString)) + { + continue; + } - if (value.QueryString is not null) - { - writer.WritePropertyName("query_string"); - JsonSerializer.Serialize(writer, value.QueryString, options); - } + if (propRefreshInterval.TryRead(ref reader, options, PropRefreshInterval)) + { + continue; + } - if (value.RefreshInterval is not null) - { - writer.WritePropertyName("refresh_interval"); - JsonSerializer.Serialize(writer, value.RefreshInterval, options); - } + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } - if (value.Routing is not null) - { - writer.WritePropertyName("routing"); - JsonSerializer.Serialize(writer, value.Routing, options); - } + if (propRoutingPartitionSize.TryRead(ref reader, options, PropRoutingPartitionSize)) + { + continue; + } - if (value.RoutingPartitionSize.HasValue) - { - writer.WritePropertyName("routing_partition_size"); - writer.WriteNumberValue(value.RoutingPartitionSize.Value); - } + if (propRoutingPath.TryRead(ref reader, options, PropRoutingPath, typeof(SingleOrManyMarker?, string>))) + { + continue; + } - if (value.RoutingPath is not null) - { - writer.WritePropertyName("routing_path"); - JsonSerializer.Serialize(writer, value.RoutingPath, options); - } + if (propSearch.TryRead(ref reader, options, PropSearch)) + { + continue; + } - if (value.Search is not null) - { - writer.WritePropertyName("search"); - JsonSerializer.Serialize(writer, value.Search, options); - } + if (propSettings.TryRead(ref reader, options, PropSettings)) + { + continue; + } - if (value.Settings is not null) - { - writer.WritePropertyName("settings"); - JsonSerializer.Serialize(writer, value.Settings, options); - } + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } - if (value.Similarity is not null) - { - writer.WritePropertyName("similarity"); - JsonSerializer.Serialize(writer, value.Similarity, options); - } + if (propSoftDeletes.TryRead(ref reader, options, PropSoftDeletes)) + { + continue; + } - if (value.SoftDeletes is not null) - { - writer.WritePropertyName("soft_deletes"); - JsonSerializer.Serialize(writer, value.SoftDeletes, options); - } + if (propSort.TryRead(ref reader, options, PropSort)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } - if (value.Store is not null) - { - writer.WritePropertyName("store"); - JsonSerializer.Serialize(writer, value.Store, options); - } + if (propTimeSeries.TryRead(ref reader, options, PropTimeSeries)) + { + continue; + } - if (value.TimeSeries is not null) - { - writer.WritePropertyName("time_series"); - JsonSerializer.Serialize(writer, value.TimeSeries, options); - } + if (propTopMetricsMaxSize.TryRead(ref reader, options, PropTopMetricsMaxSize)) + { + continue; + } - if (value.TopMetricsMaxSize.HasValue) - { - writer.WritePropertyName("top_metrics_max_size"); - writer.WriteNumberValue(value.TopMetricsMaxSize.Value); - } + if (propTranslog.TryRead(ref reader, options, PropTranslog)) + { + continue; + } - if (value.Translog is not null) - { - writer.WritePropertyName("translog"); - JsonSerializer.Serialize(writer, value.Translog, options); - } + if (propUuid.TryRead(ref reader, options, PropUuid)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Uuid)) - { - writer.WritePropertyName("uuid"); - writer.WriteStringValue(value.Uuid); - } + if (propVerifiedBeforeClose.TryRead(ref reader, options, PropVerifiedBeforeClose)) + { + continue; + } - if (value.VerifiedBeforeClose is not null) - { - writer.WritePropertyName("verified_before_close"); - JsonSerializer.Serialize(writer, value.VerifiedBeforeClose, options); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } - if (value.Version is not null) + propOtherSettings ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propOtherSettings[key] = value; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexSettings + { + OtherSettings = propOtherSettings +, + Analysis = propAnalysis.Value +, + Analyze = propAnalyze.Value +, + AutoExpandReplicas = propAutoExpandReplicas.Value +, + Blocks = propBlocks.Value +, + CheckOnStartup = propCheckOnStartup.Value +, + Codec = propCodec.Value +, + CreationDate = propCreationDate.Value +, + CreationDateString = propCreationDateString.Value +, + DefaultPipeline = propDefaultPipeline.Value +, + FinalPipeline = propFinalPipeline.Value +, + Format = propFormat.Value +, + GcDeletes = propGcDeletes.Value +, + Hidden = propHidden.Value +, + Highlight = propHighlight.Value +, + Index = propIndex.Value +, + IndexingPressure = propIndexingPressure.Value +, + IndexingSlowlog = propIndexingSlowlog.Value +, + Lifecycle = propLifecycle.Value +, + LoadFixedBitsetFiltersEagerly = propLoadFixedBitsetFiltersEagerly.Value +, + Mapping = propMapping.Value +, + MaxDocvalueFieldsSearch = propMaxDocvalueFieldsSearch.Value +, + MaxInnerResultWindow = propMaxInnerResultWindow.Value +, + MaxNgramDiff = propMaxNgramDiff.Value +, + MaxRefreshListeners = propMaxRefreshListeners.Value +, + MaxRegexLength = propMaxRegexLength.Value +, + MaxRescoreWindow = propMaxRescoreWindow.Value +, + MaxResultWindow = propMaxResultWindow.Value +, + MaxScriptFields = propMaxScriptFields.Value +, + MaxShingleDiff = propMaxShingleDiff.Value +, + MaxSlicesPerScroll = propMaxSlicesPerScroll.Value +, + MaxTermsCount = propMaxTermsCount.Value +, + Merge = propMerge.Value +, + Mode = propMode.Value +, + NumberOfReplicas = propNumberOfReplicas.Value +, + NumberOfRoutingShards = propNumberOfRoutingShards.Value +, + NumberOfShards = propNumberOfShards.Value +, + Priority = propPriority.Value +, + ProvidedName = propProvidedName.Value +, + Queries = propQueries.Value +, + QueryString = propQueryString.Value +, + RefreshInterval = propRefreshInterval.Value +, + Routing = propRouting.Value +, + RoutingPartitionSize = propRoutingPartitionSize.Value +, + RoutingPath = propRoutingPath.Value +, + Search = propSearch.Value +, + Settings = propSettings.Value +, + Similarity = propSimilarity.Value +, + SoftDeletes = propSoftDeletes.Value +, + Sort = propSort.Value +, + Store = propStore.Value +, + TimeSeries = propTimeSeries.Value +, + TopMetricsMaxSize = propTopMetricsMaxSize.Value +, + Translog = propTranslog.Value +, + Uuid = propUuid.Value +, + VerifiedBeforeClose = propVerifiedBeforeClose.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexSettings value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyze, value.Analyze); + writer.WriteProperty(options, PropAutoExpandReplicas, value.AutoExpandReplicas); + writer.WriteProperty(options, PropBlocks, value.Blocks); + writer.WriteProperty(options, PropCheckOnStartup, value.CheckOnStartup); + writer.WriteProperty(options, PropCodec, value.Codec); + writer.WriteProperty(options, PropCreationDate, value.CreationDate); + writer.WriteProperty(options, PropCreationDateString, value.CreationDateString); + writer.WriteProperty(options, PropDefaultPipeline, value.DefaultPipeline); + writer.WriteProperty(options, PropFinalPipeline, value.FinalPipeline); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGcDeletes, value.GcDeletes); + writer.WriteProperty(options, PropHidden, value.Hidden); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure); + writer.WriteProperty(options, PropIndexingSlowlog, value.IndexingSlowlog); + writer.WriteProperty(options, PropLifecycle, value.Lifecycle); + writer.WriteProperty(options, PropLoadFixedBitsetFiltersEagerly, value.LoadFixedBitsetFiltersEagerly); + writer.WriteProperty(options, PropMapping, value.Mapping); + writer.WriteProperty(options, PropMaxDocvalueFieldsSearch, value.MaxDocvalueFieldsSearch); + writer.WriteProperty(options, PropMaxInnerResultWindow, value.MaxInnerResultWindow); + writer.WriteProperty(options, PropMaxNgramDiff, value.MaxNgramDiff); + writer.WriteProperty(options, PropMaxRefreshListeners, value.MaxRefreshListeners); + writer.WriteProperty(options, PropMaxRegexLength, value.MaxRegexLength); + writer.WriteProperty(options, PropMaxRescoreWindow, value.MaxRescoreWindow); + writer.WriteProperty(options, PropMaxResultWindow, value.MaxResultWindow); + writer.WriteProperty(options, PropMaxScriptFields, value.MaxScriptFields); + writer.WriteProperty(options, PropMaxShingleDiff, value.MaxShingleDiff); + writer.WriteProperty(options, PropMaxSlicesPerScroll, value.MaxSlicesPerScroll); + writer.WriteProperty(options, PropMaxTermsCount, value.MaxTermsCount); + writer.WriteProperty(options, PropMerge, value.Merge); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNumberOfReplicas, value.NumberOfReplicas); + writer.WriteProperty(options, PropNumberOfRoutingShards, value.NumberOfRoutingShards); + writer.WriteProperty(options, PropNumberOfShards, value.NumberOfShards); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropProvidedName, value.ProvidedName); + writer.WriteProperty(options, PropQueries, value.Queries); + writer.WriteProperty(options, PropQueryString, value.QueryString); + writer.WriteProperty(options, PropRefreshInterval, value.RefreshInterval); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropRoutingPartitionSize, value.RoutingPartitionSize); + writer.WriteProperty(options, PropRoutingPath, value.RoutingPath, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropSearch, value.Search); + writer.WriteProperty(options, PropSettings, value.Settings); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropSoftDeletes, value.SoftDeletes); + writer.WriteProperty(options, PropSort, value.Sort); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeries, value.TimeSeries); + writer.WriteProperty(options, PropTopMetricsMaxSize, value.TopMetricsMaxSize); + writer.WriteProperty(options, PropTranslog, value.Translog); + writer.WriteProperty(options, PropUuid, value.Uuid); + writer.WriteProperty(options, PropVerifiedBeforeClose, value.VerifiedBeforeClose); + writer.WriteProperty(options, PropVersion, value.Version); + if (value.OtherSettings is not null) { - writer.WritePropertyName("version"); - JsonSerializer.Serialize(writer, value.Version, options); + foreach (var item in value.OtherSettings) + { + writer.WriteProperty(options, item.Key, item.Value); + } } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplate.g.cs index 69e9ad496be..57bc6e728fa 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,9 +28,132 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class IndexTemplateConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowAutoCreate = System.Text.Json.JsonEncodedText.Encode("allow_auto_create"); + private static readonly System.Text.Json.JsonEncodedText PropComposedOf = System.Text.Json.JsonEncodedText.Encode("composed_of"); + private static readonly System.Text.Json.JsonEncodedText PropDataStream = System.Text.Json.JsonEncodedText.Encode("data_stream"); + private static readonly System.Text.Json.JsonEncodedText PropDeprecated = System.Text.Json.JsonEncodedText.Encode("deprecated"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissingComponentTemplates = System.Text.Json.JsonEncodedText.Encode("ignore_missing_component_templates"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPatterns = System.Text.Json.JsonEncodedText.Encode("index_patterns"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override IndexTemplate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowAutoCreate = default; + LocalJsonProperty> propComposedOf = default; + LocalJsonProperty propDataStream = default; + LocalJsonProperty propDeprecated = default; + LocalJsonProperty?> propIgnoreMissingComponentTemplates = default; + LocalJsonProperty> propIndexPatterns = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propTemplate = default; + LocalJsonProperty propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowAutoCreate.TryRead(ref reader, options, PropAllowAutoCreate)) + { + continue; + } + + if (propComposedOf.TryRead(ref reader, options, PropComposedOf)) + { + continue; + } + + if (propDataStream.TryRead(ref reader, options, PropDataStream)) + { + continue; + } + + if (propDeprecated.TryRead(ref reader, options, PropDeprecated)) + { + continue; + } + + if (propIgnoreMissingComponentTemplates.TryRead(ref reader, options, PropIgnoreMissingComponentTemplates, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propIndexPatterns.TryRead(ref reader, options, PropIndexPatterns, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexTemplate + { + AllowAutoCreate = propAllowAutoCreate.Value +, + ComposedOf = propComposedOf.Value +, + DataStream = propDataStream.Value +, + Deprecated = propDeprecated.Value +, + IgnoreMissingComponentTemplates = propIgnoreMissingComponentTemplates.Value +, + IndexPatterns = propIndexPatterns.Value +, + Meta = propMeta.Value +, + Priority = propPriority.Value +, + Template = propTemplate.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexTemplate value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowAutoCreate, value.AllowAutoCreate); + writer.WriteProperty(options, PropComposedOf, value.ComposedOf); + writer.WriteProperty(options, PropDataStream, value.DataStream); + writer.WriteProperty(options, PropDeprecated, value.Deprecated); + writer.WriteProperty(options, PropIgnoreMissingComponentTemplates, value.IgnoreMissingComponentTemplates, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropIndexPatterns, value.IndexPatterns, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexTemplateConverter))] public sealed partial class IndexTemplate { - [JsonInclude, JsonPropertyName("allow_auto_create")] public bool? AllowAutoCreate { get; init; } /// @@ -38,7 +162,6 @@ public sealed partial class IndexTemplate /// Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. /// /// - [JsonInclude, JsonPropertyName("composed_of")] public IReadOnlyCollection ComposedOf { get; init; } /// @@ -48,7 +171,6 @@ public sealed partial class IndexTemplate /// Data streams require a matching index template with a data_stream object. /// /// - [JsonInclude, JsonPropertyName("data_stream")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateDataStreamConfiguration? DataStream { get; init; } /// @@ -58,7 +180,6 @@ public sealed partial class IndexTemplate /// Elasticsearch will emit a deprecation warning. /// /// - [JsonInclude, JsonPropertyName("deprecated")] public bool? Deprecated { get; init; } /// @@ -66,8 +187,6 @@ public sealed partial class IndexTemplate /// A list of component template names that are allowed to be absent. /// /// - [JsonInclude, JsonPropertyName("ignore_missing_component_templates")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? IgnoreMissingComponentTemplates { get; init; } /// @@ -75,8 +194,6 @@ public sealed partial class IndexTemplate /// Name of the index template. /// /// - [JsonInclude, JsonPropertyName("index_patterns")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection IndexPatterns { get; init; } /// @@ -85,7 +202,6 @@ public sealed partial class IndexTemplate /// This map is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } /// @@ -96,7 +212,6 @@ public sealed partial class IndexTemplate /// This number is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("priority")] public long? Priority { get; init; } /// @@ -105,7 +220,6 @@ public sealed partial class IndexTemplate /// It may optionally include an aliases, mappings, or settings configuration. /// /// - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateSummary? Template { get; init; } /// @@ -114,6 +228,5 @@ public sealed partial class IndexTemplate /// This number is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs index a13a65df15f..f5eabcb0122 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs @@ -38,7 +38,6 @@ public sealed partial class IndexTemplateSummary /// /// [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.Alias))] public IReadOnlyDictionary? Aliases { get; init; } [JsonInclude, JsonPropertyName("lifecycle")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamLifecycleWithRollover? Lifecycle { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs index 009836d7915..f014287edc2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal IndexUpdateAliasesAction(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IndexUpdateAliasesAction() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IndexUpdateAliasesAction Add(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.AddAction addAction) => new IndexUpdateAliasesAction("add", addAction); public static IndexUpdateAliasesAction Remove(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.RemoveAction removeAction) => new IndexUpdateAliasesAction("remove", removeAction); @@ -63,77 +68,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IndexUpdateAliasesActionConverter : JsonConverter +internal sealed partial class IndexUpdateAliasesActionConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexUpdateAliasesAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantAdd = System.Text.Json.JsonEncodedText.Encode("add"); + private static readonly System.Text.Json.JsonEncodedText VariantRemove = System.Text.Json.JsonEncodedText.Encode("remove"); + private static readonly System.Text.Json.JsonEncodedText VariantRemoveIndex = System.Text.Json.JsonEncodedText.Encode("remove_index"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override IndexUpdateAliasesAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAdd)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAdd.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove_index") + if (reader.ValueTextEquals(VariantRemoveIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IndexUpdateAliasesAction' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IndexUpdateAliasesAction(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexUpdateAliasesAction { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IndexUpdateAliasesAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexUpdateAliasesAction value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "add": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.AddAction)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.RemoveAction)value.Variant, options); - break; - case "remove_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.RemoveIndexAction)value.Variant, options); - break; - } + case "": + break; + case "add": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.AddAction?)value.Variant); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.RemoveAction?)value.Variant); + break; + case "remove_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.RemoveIndexAction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IndexUpdateAliasesAction)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/RemoveAction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/RemoveAction.g.cs index 580051e8000..4919f429184 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/RemoveAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/RemoveAction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class RemoveActionConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMustExist = System.Text.Json.JsonEncodedText.Encode("must_exist"); + + public override RemoveAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAlias = default; + LocalJsonProperty?> propAliases = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propMustExist = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryRead(ref reader, options, PropAlias)) + { + continue; + } + + if (propAliases.TryRead(ref reader, options, PropAliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexAlias>))) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propMustExist.TryRead(ref reader, options, PropMustExist)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemoveAction + { + Alias = propAlias.Value +, + Aliases = propAliases.Value +, + Index = propIndex.Value +, + Indices = propIndices.Value +, + MustExist = propMustExist.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoveAction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlias, value.Alias); + writer.WriteProperty(options, PropAliases, value.Aliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.IndexAlias>)); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropMustExist, value.MustExist); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveActionConverter))] public sealed partial class RemoveAction { /// @@ -35,7 +110,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.Serverless.IndexAlias? Alias { get; set; } /// @@ -44,8 +118,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -54,7 +126,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; } /// @@ -63,7 +134,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.Indices? Indices { get; set; } /// @@ -71,7 +141,6 @@ public sealed partial class RemoveAction /// If true, the alias must exist to perform the action. /// /// - [JsonInclude, JsonPropertyName("must_exist")] public bool? MustExist { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexUpdateAliasesAction(RemoveAction removeAction) => Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexUpdateAliasesAction.Remove(removeAction); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs index 593daf169b4..ca65afa67fb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,11 +28,52 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ResolveIndexAliasItemConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override ResolveIndexAliasItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propIndices = default; + LocalJsonProperty propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexAliasItem + { + Indices = propIndices.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexAliasItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexAliasItemConverter))] public sealed partial class ResolveIndexAliasItem { - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs index 5d6e1cd7c74..c4052c9f93f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,13 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; +internal sealed partial class ResolveIndexDataStreamsItemConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackingIndices = System.Text.Json.JsonEncodedText.Encode("backing_indices"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override ResolveIndexDataStreamsItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propBackingIndices = default; + LocalJsonProperty propName = default; + LocalJsonProperty propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryRead(ref reader, options, PropBackingIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexDataStreamsItem + { + BackingIndices = propBackingIndices.Value +, + Name = propName.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexDataStreamsItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackingIndices, value.BackingIndices, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexDataStreamsItemConverter))] public sealed partial class ResolveIndexDataStreamsItem { - [JsonInclude, JsonPropertyName("backing_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection BackingIndices { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs index bbbc27724bc..f1ec3c9c85e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -92,80 +93,70 @@ public SettingsSimilaritiesDescriptor() : base(new SettingsSimilarities()) public SettingsSimilaritiesDescriptor Scripted(string settingsSimilarityName, SettingsSimilarityScripted settingsSimilarityScripted) => AssignVariant(settingsSimilarityName, settingsSimilarityScripted); } -internal sealed partial class SettingsSimilarityInterfaceConverter : JsonConverter +internal sealed partial class SettingsSimilarityInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ISettingsSimilarity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ISettingsSimilarity Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "BM25": - return JsonSerializer.Deserialize(ref reader, options); - case "boolean": - return JsonSerializer.Deserialize(ref reader, options); - case "DFI": - return JsonSerializer.Deserialize(ref reader, options); - case "DFR": - return JsonSerializer.Deserialize(ref reader, options); - case "IB": - return JsonSerializer.Deserialize(ref reader, options); - case "LMDirichlet": - return JsonSerializer.Deserialize(ref reader, options); - case "LMJelinekMercer": - return JsonSerializer.Deserialize(ref reader, options); - case "scripted": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ISettingsSimilarity)); - return null; - } + "BM25" => reader.ReadValue(options), + "boolean" => reader.ReadValue(options), + "DFI" => reader.ReadValue(options), + "DFR" => reader.ReadValue(options), + "IB" => reader.ReadValue(options), + "LMDirichlet" => reader.ReadValue(options), + "LMJelinekMercer" => reader.ReadValue(options), + "scripted" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ISettingsSimilarity)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ISettingsSimilarity value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ISettingsSimilarity value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "BM25": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityBm25), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityBm25)value); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityBoolean), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityBoolean)value); + break; case "DFI": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityDfi), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityDfi)value); + break; case "DFR": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityDfr), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityDfr)value); + break; case "IB": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityIb), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityIb)value); + break; case "LMDirichlet": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityLmd), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityLmd)value); + break; case "LMJelinekMercer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityLmj), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityLmj)value); + break; case "scripted": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityScripted), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.IndexManagement.SettingsSimilarityScripted)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ISettingsSimilarity)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ShardStats.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ShardStats.g.cs index ff095a57b5e..6f7c6b33963 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ShardStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/ShardStats.g.cs @@ -72,7 +72,6 @@ public sealed partial class ShardStats [JsonInclude, JsonPropertyName("shard_path")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ShardPath? ShardPath { get; init; } [JsonInclude, JsonPropertyName("shards")] - [ReadOnlyIndexNameDictionaryConverter(typeof(object))] public IReadOnlyDictionary? Shards { get; init; } [JsonInclude, JsonPropertyName("shard_stats")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ShardsTotalStats? ShardStats2 { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/Template.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/Template.g.cs index d5eee844bc2..48094ed76a9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/Template.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndexManagement/Template.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement; public sealed partial class Template { [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.Alias))] public IReadOnlyDictionary Aliases { get; init; } [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TypeMapping Mappings { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndicesOptions.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndicesOptions.g.cs index a71d5c87c47..2f4f8bf58c9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndicesOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/IndicesOptions.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,12 +28,76 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class IndicesOptionsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowNoIndices = System.Text.Json.JsonEncodedText.Encode("allow_no_indices"); + private static readonly System.Text.Json.JsonEncodedText PropExpandWildcards = System.Text.Json.JsonEncodedText.Encode("expand_wildcards"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreThrottled = System.Text.Json.JsonEncodedText.Encode("ignore_throttled"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnavailable = System.Text.Json.JsonEncodedText.Encode("ignore_unavailable"); + + public override IndicesOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowNoIndices = default; + LocalJsonProperty?> propExpandWildcards = default; + LocalJsonProperty propIgnoreThrottled = default; + LocalJsonProperty propIgnoreUnavailable = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryRead(ref reader, options, PropAllowNoIndices)) + { + continue; + } + + if (propExpandWildcards.TryRead(ref reader, options, PropExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>))) + { + continue; + } + + if (propIgnoreThrottled.TryRead(ref reader, options, PropIgnoreThrottled)) + { + continue; + } + + if (propIgnoreUnavailable.TryRead(ref reader, options, PropIgnoreUnavailable)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndicesOptions + { + AllowNoIndices = propAllowNoIndices.Value +, + ExpandWildcards = propExpandWildcards.Value +, + IgnoreThrottled = propIgnoreThrottled.Value +, + IgnoreUnavailable = propIgnoreUnavailable.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicesOptions value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowNoIndices, value.AllowNoIndices); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard>)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable); + writer.WriteEndObject(); + } +} + /// /// /// Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions are expanded /// to actual indices (all, closed or open indices) and how to deal with wildcard expressions that resolve to no indices. /// /// +[JsonConverter(typeof(IndicesOptionsConverter))] public sealed partial class IndicesOptions { /// @@ -42,7 +107,6 @@ public sealed partial class IndicesOptions /// a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonInclude, JsonPropertyName("allow_no_indices")] public bool? AllowNoIndices { get; set; } /// @@ -52,8 +116,6 @@ public sealed partial class IndicesOptions /// such as open,hidden. /// /// - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } /// @@ -61,7 +123,6 @@ public sealed partial class IndicesOptions /// If true, concrete, expanded or aliased indices are ignored when frozen. /// /// - [JsonInclude, JsonPropertyName("ignore_throttled")] public bool? IgnoreThrottled { get; set; } /// @@ -69,7 +130,6 @@ public sealed partial class IndicesOptions /// If true, missing or closed indices are not included in the response. /// /// - [JsonInclude, JsonPropertyName("ignore_unavailable")] public bool? IgnoreUnavailable { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/AppendProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/AppendProcessor.g.cs index d90d96e78bf..5829abeab3c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/AppendProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/AppendProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class AppendProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowDuplicates = System.Text.Json.JsonEncodedText.Encode("allow_duplicates"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override AppendProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowDuplicates = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propField = default; + LocalJsonProperty propIf = default; + LocalJsonProperty propIgnoreFailure = default; + LocalJsonProperty?> propOnFailure = default; + LocalJsonProperty propTag = default; + LocalJsonProperty> propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowDuplicates.TryRead(ref reader, options, PropAllowDuplicates)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue, typeof(SingleOrManyMarker, object>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AppendProcessor + { + AllowDuplicates = propAllowDuplicates.Value +, + Description = propDescription.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value +, + Value = propValue.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AppendProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowDuplicates, value.AllowDuplicates); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropValue, value.Value, typeof(SingleOrManyMarker, object>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AppendProcessorConverter))] public sealed partial class AppendProcessor { /// @@ -34,7 +139,6 @@ public sealed partial class AppendProcessor /// If false, the processor does not append values already present in the field. /// /// - [JsonInclude, JsonPropertyName("allow_duplicates")] public bool? AllowDuplicates { get; set; } /// @@ -43,7 +147,6 @@ public sealed partial class AppendProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -52,7 +155,6 @@ public sealed partial class AppendProcessor /// Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -60,7 +162,6 @@ public sealed partial class AppendProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -68,7 +169,6 @@ public sealed partial class AppendProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -76,7 +176,6 @@ public sealed partial class AppendProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -85,7 +184,6 @@ public sealed partial class AppendProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -93,8 +191,6 @@ public sealed partial class AppendProcessor /// The value to be appended. Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("value")] - [SingleOrManyCollectionConverter(typeof(object))] public ICollection Value { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor(AppendProcessor appendProcessor) => Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor.Append(appendProcessor); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/CsvProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/CsvProcessor.g.cs index 697cf8aa26e..ff7c4a417b0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/CsvProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/CsvProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,150 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class CsvProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropEmptyValue = System.Text.Json.JsonEncodedText.Encode("empty_value"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropQuote = System.Text.Json.JsonEncodedText.Encode("quote"); + private static readonly System.Text.Json.JsonEncodedText PropSeparator = System.Text.Json.JsonEncodedText.Encode("separator"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropTargetFields = System.Text.Json.JsonEncodedText.Encode("target_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrim = System.Text.Json.JsonEncodedText.Encode("trim"); + + public override CsvProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDescription = default; + LocalJsonProperty propEmptyValue = default; + LocalJsonProperty propField = default; + LocalJsonProperty propIf = default; + LocalJsonProperty propIgnoreFailure = default; + LocalJsonProperty propIgnoreMissing = default; + LocalJsonProperty?> propOnFailure = default; + LocalJsonProperty propQuote = default; + LocalJsonProperty propSeparator = default; + LocalJsonProperty propTag = default; + LocalJsonProperty propTargetFields = default; + LocalJsonProperty propTrim = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propEmptyValue.TryRead(ref reader, options, PropEmptyValue)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propQuote.TryRead(ref reader, options, PropQuote)) + { + continue; + } + + if (propSeparator.TryRead(ref reader, options, PropSeparator)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propTargetFields.TryRead(ref reader, options, PropTargetFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrim.TryRead(ref reader, options, PropTrim)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CsvProcessor + { + Description = propDescription.Value +, + EmptyValue = propEmptyValue.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + OnFailure = propOnFailure.Value +, + Quote = propQuote.Value +, + Separator = propSeparator.Value +, + Tag = propTag.Value +, + TargetFields = propTargetFields.Value +, + Trim = propTrim.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CsvProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropEmptyValue, value.EmptyValue); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropQuote, value.Quote); + writer.WriteProperty(options, PropSeparator, value.Separator); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropTargetFields, value.TargetFields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrim, value.Trim); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CsvProcessorConverter))] public sealed partial class CsvProcessor { /// @@ -35,7 +180,6 @@ public sealed partial class CsvProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -45,7 +189,6 @@ public sealed partial class CsvProcessor /// An empty field is one with no value (2 consecutive separators) or empty quotes (""). /// /// - [JsonInclude, JsonPropertyName("empty_value")] public object? EmptyValue { get; set; } /// @@ -53,7 +196,6 @@ public sealed partial class CsvProcessor /// The field to extract data from. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -61,7 +203,6 @@ public sealed partial class CsvProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -69,7 +210,6 @@ public sealed partial class CsvProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -77,7 +217,6 @@ public sealed partial class CsvProcessor /// If true and field does not exist, the processor quietly exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -85,7 +224,6 @@ public sealed partial class CsvProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -93,7 +231,6 @@ public sealed partial class CsvProcessor /// Quote used in CSV, has to be single character string. /// /// - [JsonInclude, JsonPropertyName("quote")] public string? Quote { get; set; } /// @@ -101,7 +238,6 @@ public sealed partial class CsvProcessor /// Separator used in CSV, has to be single character string. /// /// - [JsonInclude, JsonPropertyName("separator")] public string? Separator { get; set; } /// @@ -110,7 +246,6 @@ public sealed partial class CsvProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -118,8 +253,6 @@ public sealed partial class CsvProcessor /// The array of fields to assign extracted values to. /// /// - [JsonInclude, JsonPropertyName("target_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields TargetFields { get; set; } /// @@ -127,7 +260,6 @@ public sealed partial class CsvProcessor /// Trim whitespaces in unquoted fields. /// /// - [JsonInclude, JsonPropertyName("trim")] public bool? Trim { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor(CsvProcessor csvProcessor) => Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor.Csv(csvProcessor); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfiguration.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfiguration.g.cs index bbe957c526a..fc9a847336e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfiguration.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfiguration.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -46,12 +47,16 @@ internal DatabaseConfiguration(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DatabaseConfiguration() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DatabaseConfiguration Ipinfo(Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo ipinfo) => new DatabaseConfiguration("ipinfo", ipinfo); public static DatabaseConfiguration Maxmind(Elastic.Clients.Elasticsearch.Serverless.Ingest.Maxmind maxmind) => new DatabaseConfiguration("maxmind", maxmind); @@ -77,83 +82,71 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DatabaseConfigurationConverter : JsonConverter +internal sealed partial class DatabaseConfigurationConverter : System.Text.Json.Serialization.JsonConverter { - public override DatabaseConfiguration Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText VariantIpinfo = System.Text.Json.JsonEncodedText.Encode("ipinfo"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxmind = System.Text.Json.JsonEncodedText.Encode("maxmind"); - object? variantValue = default; - string? variantNameValue = default; - Elastic.Clients.Elasticsearch.Serverless.Name nameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DatabaseConfiguration Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propName.TryRead(ref reader, options, PropName)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") - { - nameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantIpinfo)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "maxmind") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DatabaseConfiguration' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DatabaseConfiguration(variantNameValue, variantValue); - result.Name = nameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatabaseConfiguration + { + VariantType = variantType, + Variant = variant, + Name = propName.Value + }; } - public override void Write(Utf8JsonWriter writer, DatabaseConfiguration value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatabaseConfiguration value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Name is not null) - { - writer.WritePropertyName("name"); - JsonSerializer.Serialize(writer, value.Name, options); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Maxmind)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo?)value.Variant); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Maxmind?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfiguration)}'."); } + writer.WriteProperty(options, PropName, value.Name); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs index 74ed0662918..db01604b5b3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal DatabaseConfigurationFull(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DatabaseConfigurationFull() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DatabaseConfigurationFull Ipinfo(Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo ipinfo) => new DatabaseConfigurationFull("ipinfo", ipinfo); public static DatabaseConfigurationFull Local(Elastic.Clients.Elasticsearch.Serverless.Ingest.Local local) => new DatabaseConfigurationFull("local", local); @@ -72,103 +77,95 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DatabaseConfigurationFullConverter : JsonConverter +internal sealed partial class DatabaseConfigurationFullConverter : System.Text.Json.Serialization.JsonConverter { - public override DatabaseConfigurationFull Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText VariantIpinfo = System.Text.Json.JsonEncodedText.Encode("ipinfo"); + private static readonly System.Text.Json.JsonEncodedText VariantLocal = System.Text.Json.JsonEncodedText.Encode("local"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxmind = System.Text.Json.JsonEncodedText.Encode("maxmind"); + private static readonly System.Text.Json.JsonEncodedText VariantWeb = System.Text.Json.JsonEncodedText.Encode("web"); - object? variantValue = default; - string? variantNameValue = default; - string nameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DatabaseConfigurationFull Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propName.TryRead(ref reader, options, PropName)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") - { - nameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantIpinfo)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "local") + if (reader.ValueTextEquals(VariantLocal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLocal.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "maxmind") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "web") + if (reader.ValueTextEquals(VariantWeb)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeb.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DatabaseConfigurationFull' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DatabaseConfigurationFull(variantNameValue, variantValue); - result.Name = nameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatabaseConfigurationFull + { + VariantType = variantType, + Variant = variant, + Name = propName.Value + }; } - public override void Write(Utf8JsonWriter writer, DatabaseConfigurationFull value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatabaseConfigurationFull value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Name)) - { - writer.WritePropertyName("name"); - writer.WriteStringValue(value.Name); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo)value.Variant, options); - break; - case "local": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Local)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Maxmind)value.Variant, options); - break; - case "web": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Web)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Ipinfo?)value.Variant); + break; + case "local": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Local?)value.Variant); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Maxmind?)value.Variant); + break; + case "web": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.Web?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfigurationFull)}'."); } + writer.WriteProperty(options, PropName, value.Name); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DocumentSimulation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DocumentSimulation.g.cs index 3a91b937cf8..f4e28239b03 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DocumentSimulation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/DocumentSimulation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,79 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; -internal sealed partial class DocumentSimulationConverter : JsonConverter +internal sealed partial class DocumentSimulationConverter : System.Text.Json.Serialization.JsonConverter { - public override DocumentSimulation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("_ingest"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("_version_type"); + + public override DocumentSimulation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - string id = default; - string index = default; - Elastic.Clients.Elasticsearch.Serverless.Ingest.Ingest ingest = default; - string? routing = default; - IReadOnlyDictionary source = default; - long? version = default; - Elastic.Clients.Elasticsearch.Serverless.VersionType? versionType = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIngest = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty> propSource = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propId.TryRead(ref reader, options, PropId)) { - var property = reader.GetString(); - if (property == "_id") - { - id = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_index") - { - index = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_ingest") - { - ingest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_routing") - { - routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - source = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "_version") - { - version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_version_type") - { - versionType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out string value); + propMetadata[key] = value; } - return new DocumentSimulation { Id = id, Index = index, Ingest = ingest, Metadata = additionalProperties, Routing = routing, Source = source, Version = version, VersionType = versionType }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DocumentSimulation + { + Metadata = propMetadata +, + Id = propId.Value +, + Index = propIndex.Value +, + Ingest = propIngest.Value +, + Routing = propRouting.Value +, + Source = propSource.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; } - public override void Write(Utf8JsonWriter writer, DocumentSimulation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DocumentSimulation value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DocumentSimulation' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/FingerprintProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/FingerprintProcessor.g.cs index 810dbfa3704..a7fd647052e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/FingerprintProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/FingerprintProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,130 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class FingerprintProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropMethod = System.Text.Json.JsonEncodedText.Encode("method"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropSalt = System.Text.Json.JsonEncodedText.Encode("salt"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropTargetField = System.Text.Json.JsonEncodedText.Encode("target_field"); + + public override FingerprintProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDescription = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIf = default; + LocalJsonProperty propIgnoreFailure = default; + LocalJsonProperty propIgnoreMissing = default; + LocalJsonProperty propMethod = default; + LocalJsonProperty?> propOnFailure = default; + LocalJsonProperty propSalt = default; + LocalJsonProperty propTag = default; + LocalJsonProperty propTargetField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propMethod.TryRead(ref reader, options, PropMethod)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propSalt.TryRead(ref reader, options, PropSalt)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propTargetField.TryRead(ref reader, options, PropTargetField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FingerprintProcessor + { + Description = propDescription.Value +, + Fields = propFields.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + Method = propMethod.Value +, + OnFailure = propOnFailure.Value +, + Salt = propSalt.Value +, + Tag = propTag.Value +, + TargetField = propTargetField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropMethod, value.Method); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropSalt, value.Salt); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropTargetField, value.TargetField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FingerprintProcessorConverter))] public sealed partial class FingerprintProcessor { /// @@ -35,7 +160,6 @@ public sealed partial class FingerprintProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -45,8 +169,6 @@ public sealed partial class FingerprintProcessor /// only the field value. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields Fields { get; set; } /// @@ -54,7 +176,6 @@ public sealed partial class FingerprintProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -62,7 +183,6 @@ public sealed partial class FingerprintProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -71,7 +191,6 @@ public sealed partial class FingerprintProcessor /// missing, the processor silently exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -80,7 +199,6 @@ public sealed partial class FingerprintProcessor /// SHA-256, SHA-512, or MurmurHash3. /// /// - [JsonInclude, JsonPropertyName("method")] public Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintDigest? Method { get; set; } /// @@ -88,7 +206,6 @@ public sealed partial class FingerprintProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -96,7 +213,6 @@ public sealed partial class FingerprintProcessor /// Salt value for the hash function. /// /// - [JsonInclude, JsonPropertyName("salt")] public string? Salt { get; set; } /// @@ -105,7 +221,6 @@ public sealed partial class FingerprintProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -113,7 +228,6 @@ public sealed partial class FingerprintProcessor /// Output field for the fingerprint. /// /// - [JsonInclude, JsonPropertyName("target_field")] public Elastic.Clients.Elasticsearch.Serverless.Field? TargetField { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor(FingerprintProcessor fingerprintProcessor) => Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor.Fingerprint(fingerprintProcessor); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/InferenceConfig.g.cs index 7d79f093d47..c602221561d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/InferenceConfig.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal InferenceConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfig Classification(Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigClassification inferenceConfigClassification) => new InferenceConfig("classification", inferenceConfigClassification); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigRegression inferenceConfigRegression) => new InferenceConfig("regression", inferenceConfigRegression); @@ -62,67 +67,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigConverter : JsonConverter +internal sealed partial class InferenceConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override InferenceConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigClassification)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigClassification?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceConfigRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/Processor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/Processor.g.cs index f464444d218..eef15711e00 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/Processor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/Processor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Processor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Processor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Processor Append(Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor appendProcessor) => new Processor("append", appendProcessor); public static Processor Attachment(Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor attachmentProcessor) => new Processor("attachment", attachmentProcessor); @@ -105,497 +110,572 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class ProcessorConverter : JsonConverter +internal sealed partial class ProcessorConverter : System.Text.Json.Serialization.JsonConverter { - public override Processor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAppend = System.Text.Json.JsonEncodedText.Encode("append"); + private static readonly System.Text.Json.JsonEncodedText VariantAttachment = System.Text.Json.JsonEncodedText.Encode("attachment"); + private static readonly System.Text.Json.JsonEncodedText VariantBytes = System.Text.Json.JsonEncodedText.Encode("bytes"); + private static readonly System.Text.Json.JsonEncodedText VariantCircle = System.Text.Json.JsonEncodedText.Encode("circle"); + private static readonly System.Text.Json.JsonEncodedText VariantCommunityId = System.Text.Json.JsonEncodedText.Encode("community_id"); + private static readonly System.Text.Json.JsonEncodedText VariantConvert = System.Text.Json.JsonEncodedText.Encode("convert"); + private static readonly System.Text.Json.JsonEncodedText VariantCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText VariantDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText VariantDateIndexName = System.Text.Json.JsonEncodedText.Encode("date_index_name"); + private static readonly System.Text.Json.JsonEncodedText VariantDissect = System.Text.Json.JsonEncodedText.Encode("dissect"); + private static readonly System.Text.Json.JsonEncodedText VariantDotExpander = System.Text.Json.JsonEncodedText.Encode("dot_expander"); + private static readonly System.Text.Json.JsonEncodedText VariantDrop = System.Text.Json.JsonEncodedText.Encode("drop"); + private static readonly System.Text.Json.JsonEncodedText VariantEnrich = System.Text.Json.JsonEncodedText.Encode("enrich"); + private static readonly System.Text.Json.JsonEncodedText VariantFail = System.Text.Json.JsonEncodedText.Encode("fail"); + private static readonly System.Text.Json.JsonEncodedText VariantFingerprint = System.Text.Json.JsonEncodedText.Encode("fingerprint"); + private static readonly System.Text.Json.JsonEncodedText VariantForeach = System.Text.Json.JsonEncodedText.Encode("foreach"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoGrid = System.Text.Json.JsonEncodedText.Encode("geo_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoip = System.Text.Json.JsonEncodedText.Encode("geoip"); + private static readonly System.Text.Json.JsonEncodedText VariantGrok = System.Text.Json.JsonEncodedText.Encode("grok"); + private static readonly System.Text.Json.JsonEncodedText VariantGsub = System.Text.Json.JsonEncodedText.Encode("gsub"); + private static readonly System.Text.Json.JsonEncodedText VariantHtmlStrip = System.Text.Json.JsonEncodedText.Encode("html_strip"); + private static readonly System.Text.Json.JsonEncodedText VariantInference = System.Text.Json.JsonEncodedText.Encode("inference"); + private static readonly System.Text.Json.JsonEncodedText VariantIpLocation = System.Text.Json.JsonEncodedText.Encode("ip_location"); + private static readonly System.Text.Json.JsonEncodedText VariantJoin = System.Text.Json.JsonEncodedText.Encode("join"); + private static readonly System.Text.Json.JsonEncodedText VariantJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText VariantKv = System.Text.Json.JsonEncodedText.Encode("kv"); + private static readonly System.Text.Json.JsonEncodedText VariantLowercase = System.Text.Json.JsonEncodedText.Encode("lowercase"); + private static readonly System.Text.Json.JsonEncodedText VariantNetworkDirection = System.Text.Json.JsonEncodedText.Encode("network_direction"); + private static readonly System.Text.Json.JsonEncodedText VariantPipeline = System.Text.Json.JsonEncodedText.Encode("pipeline"); + private static readonly System.Text.Json.JsonEncodedText VariantRedact = System.Text.Json.JsonEncodedText.Encode("redact"); + private static readonly System.Text.Json.JsonEncodedText VariantRegisteredDomain = System.Text.Json.JsonEncodedText.Encode("registered_domain"); + private static readonly System.Text.Json.JsonEncodedText VariantRemove = System.Text.Json.JsonEncodedText.Encode("remove"); + private static readonly System.Text.Json.JsonEncodedText VariantRename = System.Text.Json.JsonEncodedText.Encode("rename"); + private static readonly System.Text.Json.JsonEncodedText VariantReroute = System.Text.Json.JsonEncodedText.Encode("reroute"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText VariantSet = System.Text.Json.JsonEncodedText.Encode("set"); + private static readonly System.Text.Json.JsonEncodedText VariantSetSecurityUser = System.Text.Json.JsonEncodedText.Encode("set_security_user"); + private static readonly System.Text.Json.JsonEncodedText VariantSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText VariantSplit = System.Text.Json.JsonEncodedText.Encode("split"); + private static readonly System.Text.Json.JsonEncodedText VariantTerminate = System.Text.Json.JsonEncodedText.Encode("terminate"); + private static readonly System.Text.Json.JsonEncodedText VariantTrim = System.Text.Json.JsonEncodedText.Encode("trim"); + private static readonly System.Text.Json.JsonEncodedText VariantUppercase = System.Text.Json.JsonEncodedText.Encode("uppercase"); + private static readonly System.Text.Json.JsonEncodedText VariantUriParts = System.Text.Json.JsonEncodedText.Encode("uri_parts"); + private static readonly System.Text.Json.JsonEncodedText VariantUrlDecode = System.Text.Json.JsonEncodedText.Encode("urldecode"); + private static readonly System.Text.Json.JsonEncodedText VariantUserAgent = System.Text.Json.JsonEncodedText.Encode("user_agent"); + + public override Processor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAppend)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "append") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAppend.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "attachment") + if (reader.ValueTextEquals(VariantAttachment)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAttachment.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bytes") + if (reader.ValueTextEquals(VariantBytes)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBytes.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "circle") + if (reader.ValueTextEquals(VariantCircle)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCircle.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "community_id") + if (reader.ValueTextEquals(VariantCommunityId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCommunityId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "convert") + if (reader.ValueTextEquals(VariantConvert)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConvert.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "csv") + if (reader.ValueTextEquals(VariantCsv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCsv.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date") + if (reader.ValueTextEquals(VariantDate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_index_name") + if (reader.ValueTextEquals(VariantDateIndexName)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateIndexName.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dissect") + if (reader.ValueTextEquals(VariantDissect)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDissect.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dot_expander") + if (reader.ValueTextEquals(VariantDotExpander)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDotExpander.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "drop") + if (reader.ValueTextEquals(VariantDrop)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDrop.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "enrich") + if (reader.ValueTextEquals(VariantEnrich)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantEnrich.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fail") + if (reader.ValueTextEquals(VariantFail)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFail.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fingerprint") + if (reader.ValueTextEquals(VariantFingerprint)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFingerprint.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "foreach") + if (reader.ValueTextEquals(VariantForeach)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantForeach.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_grid") + if (reader.ValueTextEquals(VariantGeoGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geoip") + if (reader.ValueTextEquals(VariantGeoip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoip.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "grok") + if (reader.ValueTextEquals(VariantGrok)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGrok.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "gsub") + if (reader.ValueTextEquals(VariantGsub)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGsub.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "html_strip") + if (reader.ValueTextEquals(VariantHtmlStrip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHtmlStrip.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_location") + if (reader.ValueTextEquals(VariantIpLocation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpLocation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "join") + if (reader.ValueTextEquals(VariantJoin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJoin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "json") + if (reader.ValueTextEquals(VariantJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJson.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "kv") + if (reader.ValueTextEquals(VariantKv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKv.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "lowercase") + if (reader.ValueTextEquals(VariantLowercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLowercase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "network_direction") + if (reader.ValueTextEquals(VariantNetworkDirection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNetworkDirection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pipeline") + if (reader.ValueTextEquals(VariantPipeline)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPipeline.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "redact") + if (reader.ValueTextEquals(VariantRedact)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRedact.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "registered_domain") + if (reader.ValueTextEquals(VariantRegisteredDomain)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegisteredDomain.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rename") + if (reader.ValueTextEquals(VariantRename)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRename.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "reroute") + if (reader.ValueTextEquals(VariantReroute)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReroute.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "set") + if (reader.ValueTextEquals(VariantSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "set_security_user") + if (reader.ValueTextEquals(VariantSetSecurityUser)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSetSecurityUser.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sort") + if (reader.ValueTextEquals(VariantSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSort.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "split") + if (reader.ValueTextEquals(VariantSplit)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSplit.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terminate") + if (reader.ValueTextEquals(VariantTerminate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerminate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "trim") + if (reader.ValueTextEquals(VariantTrim)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTrim.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "uppercase") + if (reader.ValueTextEquals(VariantUppercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUppercase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "uri_parts") + if (reader.ValueTextEquals(VariantUriParts)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUriParts.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "urldecode") + if (reader.ValueTextEquals(VariantUrlDecode)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUrlDecode.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "user_agent") + if (reader.ValueTextEquals(VariantUserAgent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUserAgent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Processor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Processor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Processor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Processor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Processor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "append": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor)value.Variant, options); - break; - case "attachment": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor)value.Variant, options); - break; - case "bytes": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor)value.Variant, options); - break; - case "circle": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor)value.Variant, options); - break; - case "community_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor)value.Variant, options); - break; - case "convert": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor)value.Variant, options); - break; - case "csv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor)value.Variant, options); - break; - case "date": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor)value.Variant, options); - break; - case "date_index_name": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor)value.Variant, options); - break; - case "dissect": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor)value.Variant, options); - break; - case "dot_expander": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor)value.Variant, options); - break; - case "drop": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor)value.Variant, options); - break; - case "enrich": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor)value.Variant, options); - break; - case "fail": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor)value.Variant, options); - break; - case "fingerprint": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor)value.Variant, options); - break; - case "foreach": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor)value.Variant, options); - break; - case "geo_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor)value.Variant, options); - break; - case "geoip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor)value.Variant, options); - break; - case "grok": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor)value.Variant, options); - break; - case "gsub": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor)value.Variant, options); - break; - case "html_strip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor)value.Variant, options); - break; - case "ip_location": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.IpLocationProcessor)value.Variant, options); - break; - case "join": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor)value.Variant, options); - break; - case "json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor)value.Variant, options); - break; - case "kv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor)value.Variant, options); - break; - case "lowercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor)value.Variant, options); - break; - case "network_direction": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor)value.Variant, options); - break; - case "pipeline": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor)value.Variant, options); - break; - case "redact": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor)value.Variant, options); - break; - case "registered_domain": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor)value.Variant, options); - break; - case "rename": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor)value.Variant, options); - break; - case "reroute": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor)value.Variant, options); - break; - case "set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor)value.Variant, options); - break; - case "set_security_user": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor)value.Variant, options); - break; - case "sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor)value.Variant, options); - break; - case "split": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor)value.Variant, options); - break; - case "terminate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor)value.Variant, options); - break; - case "trim": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor)value.Variant, options); - break; - case "uppercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor)value.Variant, options); - break; - case "uri_parts": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor)value.Variant, options); - break; - case "urldecode": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor)value.Variant, options); - break; - case "user_agent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor)value.Variant, options); - break; - } + case "": + break; + case "append": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AppendProcessor?)value.Variant); + break; + case "attachment": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.AttachmentProcessor?)value.Variant); + break; + case "bytes": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.BytesProcessor?)value.Variant); + break; + case "circle": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CircleProcessor?)value.Variant); + break; + case "community_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CommunityIDProcessor?)value.Variant); + break; + case "convert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ConvertProcessor?)value.Variant); + break; + case "csv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.CsvProcessor?)value.Variant); + break; + case "date": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateProcessor?)value.Variant); + break; + case "date_index_name": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DateIndexNameProcessor?)value.Variant); + break; + case "dissect": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DissectProcessor?)value.Variant); + break; + case "dot_expander": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DotExpanderProcessor?)value.Variant); + break; + case "drop": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.DropProcessor?)value.Variant); + break; + case "enrich": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.EnrichProcessor?)value.Variant); + break; + case "fail": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FailProcessor?)value.Variant); + break; + case "fingerprint": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.FingerprintProcessor?)value.Variant); + break; + case "foreach": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ForeachProcessor?)value.Variant); + break; + case "geo_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoGridProcessor?)value.Variant); + break; + case "geoip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GeoIpProcessor?)value.Variant); + break; + case "grok": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GrokProcessor?)value.Variant); + break; + case "gsub": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.GsubProcessor?)value.Variant); + break; + case "html_strip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.HtmlStripProcessor?)value.Variant); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.InferenceProcessor?)value.Variant); + break; + case "ip_location": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.IpLocationProcessor?)value.Variant); + break; + case "join": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JoinProcessor?)value.Variant); + break; + case "json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.JsonProcessor?)value.Variant); + break; + case "kv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.KeyValueProcessor?)value.Variant); + break; + case "lowercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.LowercaseProcessor?)value.Variant); + break; + case "network_direction": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.NetworkDirectionProcessor?)value.Variant); + break; + case "pipeline": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.PipelineProcessor?)value.Variant); + break; + case "redact": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RedactProcessor?)value.Variant); + break; + case "registered_domain": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RegisteredDomainProcessor?)value.Variant); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RemoveProcessor?)value.Variant); + break; + case "rename": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RenameProcessor?)value.Variant); + break; + case "reroute": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.RerouteProcessor?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.ScriptProcessor?)value.Variant); + break; + case "set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetProcessor?)value.Variant); + break; + case "set_security_user": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SetSecurityUserProcessor?)value.Variant); + break; + case "sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SortProcessor?)value.Variant); + break; + case "split": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.SplitProcessor?)value.Variant); + break; + case "terminate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TerminateProcessor?)value.Variant); + break; + case "trim": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.TrimProcessor?)value.Variant); + break; + case "uppercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UppercaseProcessor?)value.Variant); + break; + case "uri_parts": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UriPartsProcessor?)value.Variant); + break; + case "urldecode": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UrlDecodeProcessor?)value.Variant); + break; + case "user_agent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Ingest.UserAgentProcessor?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Processor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RemoveProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RemoveProcessor.g.cs index f6f877bc357..647e28859f7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RemoveProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RemoveProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class RemoveProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropKeep = System.Text.Json.JsonEncodedText.Encode("keep"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + + public override RemoveProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDescription = default; + LocalJsonProperty propField = default; + LocalJsonProperty propIf = default; + LocalJsonProperty propIgnoreFailure = default; + LocalJsonProperty propIgnoreMissing = default; + LocalJsonProperty propKeep = default; + LocalJsonProperty?> propOnFailure = default; + LocalJsonProperty propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propKeep.TryRead(ref reader, options, PropKeep, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemoveProcessor + { + Description = propDescription.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + Keep = propKeep.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoveProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropField, value.Field, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropKeep, value.Keep, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveProcessorConverter))] public sealed partial class RemoveProcessor { /// @@ -35,7 +140,6 @@ public sealed partial class RemoveProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -43,8 +147,6 @@ public sealed partial class RemoveProcessor /// Fields to be removed. Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields Field { get; set; } /// @@ -52,7 +154,6 @@ public sealed partial class RemoveProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -60,7 +161,6 @@ public sealed partial class RemoveProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -68,7 +168,6 @@ public sealed partial class RemoveProcessor /// If true and field does not exist or is null, the processor quietly exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -76,8 +175,6 @@ public sealed partial class RemoveProcessor /// Fields to be kept. When set, all fields other than those specified are removed. /// /// - [JsonInclude, JsonPropertyName("keep")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Keep { get; set; } /// @@ -85,7 +182,6 @@ public sealed partial class RemoveProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -94,7 +190,6 @@ public sealed partial class RemoveProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor(RemoveProcessor removeProcessor) => Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor.Remove(removeProcessor); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RerouteProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RerouteProcessor.g.cs index 1e865f6735a..a6a47120ac4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RerouteProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Ingest/RerouteProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Ingest; +internal sealed partial class RerouteProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataset = System.Text.Json.JsonEncodedText.Encode("dataset"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDestination = System.Text.Json.JsonEncodedText.Encode("destination"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropNamespace = System.Text.Json.JsonEncodedText.Encode("namespace"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + + public override RerouteProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propDataset = default; + LocalJsonProperty propDescription = default; + LocalJsonProperty propDestination = default; + LocalJsonProperty propIf = default; + LocalJsonProperty propIgnoreFailure = default; + LocalJsonProperty?> propNamespace = default; + LocalJsonProperty?> propOnFailure = default; + LocalJsonProperty propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataset.TryRead(ref reader, options, PropDataset, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDestination.TryRead(ref reader, options, PropDestination)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propNamespace.TryRead(ref reader, options, PropNamespace, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RerouteProcessor + { + Dataset = propDataset.Value +, + Description = propDescription.Value +, + Destination = propDestination.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + Namespace = propNamespace.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RerouteProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataset, value.Dataset, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDestination, value.Destination); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropNamespace, value.Namespace, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RerouteProcessorConverter))] public sealed partial class RerouteProcessor { /// @@ -44,8 +149,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.dataset}} /// /// - [JsonInclude, JsonPropertyName("dataset")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Dataset { get; set; } /// @@ -54,7 +157,6 @@ public sealed partial class RerouteProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -62,7 +164,6 @@ public sealed partial class RerouteProcessor /// A static value for the target. Can’t be set when the dataset or namespace option is set. /// /// - [JsonInclude, JsonPropertyName("destination")] public string? Destination { get; set; } /// @@ -70,7 +171,6 @@ public sealed partial class RerouteProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -78,7 +178,6 @@ public sealed partial class RerouteProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -95,8 +194,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.namespace}} /// /// - [JsonInclude, JsonPropertyName("namespace")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Namespace { get; set; } /// @@ -104,7 +201,6 @@ public sealed partial class RerouteProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -113,7 +209,6 @@ public sealed partial class RerouteProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor(RerouteProcessor rerouteProcessor) => Elastic.Clients.Elasticsearch.Serverless.Ingest.Processor.Reroute(rerouteProcessor); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/InlineGet.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/InlineGet.g.cs index 0ecc654b5b4..32992bea636 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/InlineGet.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/InlineGet.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,76 +28,121 @@ namespace Elastic.Clients.Elasticsearch.Serverless; -internal sealed partial class InlineGetConverter : JsonConverter> +internal sealed partial class InlineGetConverter : System.Text.Json.Serialization.JsonConverter> { - public override InlineGet Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override InlineGet Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? fields = default; - bool found = default; - long? primaryTerm = default; - string? routing = default; - long? seqNo = default; - TDocument? source = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonProperty?> propFields = default; + LocalJsonProperty propFound = default; + LocalJsonProperty propPrimaryTerm = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propSeqNo = default; + LocalJsonProperty propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) { - var property = reader.GetString(); - if (property == "fields") - { - fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "found") - { - found = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_primary_term") - { - primaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_routing") - { - routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_seq_no") - { - seqNo = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propMetadata[key] = value; } - return new InlineGet { Fields = fields, Found = found, Metadata = additionalProperties, PrimaryTerm = primaryTerm, Routing = routing, SeqNo = seqNo, Source = source }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InlineGet + { + Metadata = propMetadata +, + Fields = propFields.Value +, + Found = propFound.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InlineGet value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, typeof(SourceMarker)); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); + } +} + +internal sealed partial class InlineGetConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(InlineGet<>); } - public override void Write(Utf8JsonWriter writer, InlineGet value, JsonSerializerOptions options) + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'InlineGet' is a readonly type, used only on responses and does not support being written to JSON."); + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(InlineGetConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; } } -[GenericConverter(typeof(InlineGetConverter<>), unwrap: true)] +[JsonConverter(typeof(InlineGetConverterFactory))] public sealed partial class InlineGet { public IReadOnlyDictionary? Fields { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnQuery.g.cs index 5c7e205c5ae..6846bb777b9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,120 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class KnnQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propField = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propk = default; + LocalJsonProperty propNumCandidates = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty?> propQueryVector = default; + LocalJsonProperty propQueryVectorBuilder = default; + LocalJsonProperty propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + k = propk.Value +, + NumCandidates = propNumCandidates.Value +, + QueryName = propQueryName.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnQueryConverter))] public sealed partial class KnnQuery { /// @@ -37,7 +152,6 @@ public sealed partial class KnnQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -45,7 +159,6 @@ public sealed partial class KnnQuery /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -53,8 +166,6 @@ public sealed partial class KnnQuery /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -62,7 +173,6 @@ public sealed partial class KnnQuery /// The final number of nearest neighbors to return as top hits /// /// - [JsonInclude, JsonPropertyName("k")] public int? k { get; set; } /// @@ -70,9 +180,7 @@ public sealed partial class KnnQuery /// The number of nearest neighbor candidates to consider per shard /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int? NumCandidates { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -80,7 +188,6 @@ public sealed partial class KnnQuery /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -88,7 +195,6 @@ public sealed partial class KnnQuery /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.Serverless.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -96,7 +202,6 @@ public sealed partial class KnnQuery /// The minimum similarity for a vector to be considered a match /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(KnnQuery knnQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.Knn(knnQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnRetriever.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnRetriever.g.cs index 12e19169c80..7c020844924 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnRetriever.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class KnnRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propk = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propNumCandidates = default; + LocalJsonProperty?> propQueryVector = default; + LocalJsonProperty propQueryVectorBuilder = default; + LocalJsonProperty propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnRetriever + { + Field = propField.Value +, + Filter = propFilter.Value +, + k = propk.Value +, + MinScore = propMinScore.Value +, + NumCandidates = propNumCandidates.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnRetrieverConverter))] public sealed partial class KnnRetriever { /// @@ -34,7 +139,6 @@ public sealed partial class KnnRetriever /// The name of the vector field to search against. /// /// - [JsonInclude, JsonPropertyName("field")] public string Field { get; set; } /// @@ -42,8 +146,6 @@ public sealed partial class KnnRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -51,7 +153,6 @@ public sealed partial class KnnRetriever /// Number of nearest neighbors to return as top hits. /// /// - [JsonInclude, JsonPropertyName("k")] public int k { get; set; } /// @@ -59,7 +160,6 @@ public sealed partial class KnnRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -67,7 +167,6 @@ public sealed partial class KnnRetriever /// Number of nearest neighbor candidates to consider per shard. /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int NumCandidates { get; set; } /// @@ -75,7 +174,6 @@ public sealed partial class KnnRetriever /// Query vector. Must have the same number of dimensions as the vector field you are searching against. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -83,7 +181,6 @@ public sealed partial class KnnRetriever /// Defines a model to build a query vector. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.Serverless.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -91,7 +188,6 @@ public sealed partial class KnnRetriever /// The minimum similarity required for a document to be considered a match. /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Retriever(KnnRetriever knnRetriever) => Elastic.Clients.Elasticsearch.Serverless.Retriever.Knn(knnRetriever); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnSearch.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnSearch.g.cs index a1deddb0eb4..27fe09f5c5c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/KnnSearch.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,120 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class KnnSearchConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnSearch Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propField = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propInnerHits = default; + LocalJsonProperty propk = default; + LocalJsonProperty propNumCandidates = default; + LocalJsonProperty?> propQueryVector = default; + LocalJsonProperty propQueryVectorBuilder = default; + LocalJsonProperty propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits)) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnSearch + { + Boost = propBoost.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + InnerHits = propInnerHits.Value +, + k = propk.Value +, + NumCandidates = propNumCandidates.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnSearch value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropInnerHits, value.InnerHits); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnSearchConverter))] public sealed partial class KnnSearch { /// @@ -34,7 +149,6 @@ public sealed partial class KnnSearch /// Boost value to apply to kNN scores /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -42,7 +156,6 @@ public sealed partial class KnnSearch /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -50,8 +163,6 @@ public sealed partial class KnnSearch /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -59,7 +170,6 @@ public sealed partial class KnnSearch /// If defined, each search hit will contain inner hits. /// /// - [JsonInclude, JsonPropertyName("inner_hits")] public Elastic.Clients.Elasticsearch.Serverless.Core.Search.InnerHits? InnerHits { get; set; } /// @@ -67,7 +177,6 @@ public sealed partial class KnnSearch /// The final number of nearest neighbors to return as top hits /// /// - [JsonInclude, JsonPropertyName("k")] public int? k { get; set; } /// @@ -75,7 +184,6 @@ public sealed partial class KnnSearch /// The number of nearest neighbor candidates to consider per shard /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int? NumCandidates { get; set; } /// @@ -83,7 +191,6 @@ public sealed partial class KnnSearch /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -91,7 +198,6 @@ public sealed partial class KnnSearch /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.Serverless.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -99,7 +205,6 @@ public sealed partial class KnnSearch /// The minimum similarity for a vector to be considered a match /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/AnalysisConfig.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/AnalysisConfig.g.cs index 9335a95cc9c..bccf26f4e39 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/AnalysisConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/AnalysisConfig.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,140 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class AnalysisConfigConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBucketSpan = System.Text.Json.JsonEncodedText.Encode("bucket_span"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationAnalyzer = System.Text.Json.JsonEncodedText.Encode("categorization_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationFieldName = System.Text.Json.JsonEncodedText.Encode("categorization_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationFilters = System.Text.Json.JsonEncodedText.Encode("categorization_filters"); + private static readonly System.Text.Json.JsonEncodedText PropDetectors = System.Text.Json.JsonEncodedText.Encode("detectors"); + private static readonly System.Text.Json.JsonEncodedText PropInfluencers = System.Text.Json.JsonEncodedText.Encode("influencers"); + private static readonly System.Text.Json.JsonEncodedText PropLatency = System.Text.Json.JsonEncodedText.Encode("latency"); + private static readonly System.Text.Json.JsonEncodedText PropModelPruneWindow = System.Text.Json.JsonEncodedText.Encode("model_prune_window"); + private static readonly System.Text.Json.JsonEncodedText PropMultivariateByFields = System.Text.Json.JsonEncodedText.Encode("multivariate_by_fields"); + private static readonly System.Text.Json.JsonEncodedText PropPerPartitionCategorization = System.Text.Json.JsonEncodedText.Encode("per_partition_categorization"); + private static readonly System.Text.Json.JsonEncodedText PropSummaryCountFieldName = System.Text.Json.JsonEncodedText.Encode("summary_count_field_name"); + + public override AnalysisConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBucketSpan = default; + LocalJsonProperty propCategorizationAnalyzer = default; + LocalJsonProperty propCategorizationFieldName = default; + LocalJsonProperty?> propCategorizationFilters = default; + LocalJsonProperty> propDetectors = default; + LocalJsonProperty propInfluencers = default; + LocalJsonProperty propLatency = default; + LocalJsonProperty propModelPruneWindow = default; + LocalJsonProperty propMultivariateByFields = default; + LocalJsonProperty propPerPartitionCategorization = default; + LocalJsonProperty propSummaryCountFieldName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBucketSpan.TryRead(ref reader, options, PropBucketSpan)) + { + continue; + } + + if (propCategorizationAnalyzer.TryRead(ref reader, options, PropCategorizationAnalyzer)) + { + continue; + } + + if (propCategorizationFieldName.TryRead(ref reader, options, PropCategorizationFieldName)) + { + continue; + } + + if (propCategorizationFilters.TryRead(ref reader, options, PropCategorizationFilters)) + { + continue; + } + + if (propDetectors.TryRead(ref reader, options, PropDetectors)) + { + continue; + } + + if (propInfluencers.TryRead(ref reader, options, PropInfluencers, typeof(FieldsMarker))) + { + continue; + } + + if (propLatency.TryRead(ref reader, options, PropLatency)) + { + continue; + } + + if (propModelPruneWindow.TryRead(ref reader, options, PropModelPruneWindow)) + { + continue; + } + + if (propMultivariateByFields.TryRead(ref reader, options, PropMultivariateByFields)) + { + continue; + } + + if (propPerPartitionCategorization.TryRead(ref reader, options, PropPerPartitionCategorization)) + { + continue; + } + + if (propSummaryCountFieldName.TryRead(ref reader, options, PropSummaryCountFieldName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalysisConfig + { + BucketSpan = propBucketSpan.Value +, + CategorizationAnalyzer = propCategorizationAnalyzer.Value +, + CategorizationFieldName = propCategorizationFieldName.Value +, + CategorizationFilters = propCategorizationFilters.Value +, + Detectors = propDetectors.Value +, + Influencers = propInfluencers.Value +, + Latency = propLatency.Value +, + ModelPruneWindow = propModelPruneWindow.Value +, + MultivariateByFields = propMultivariateByFields.Value +, + PerPartitionCategorization = propPerPartitionCategorization.Value +, + SummaryCountFieldName = propSummaryCountFieldName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalysisConfig value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBucketSpan, value.BucketSpan); + writer.WriteProperty(options, PropCategorizationAnalyzer, value.CategorizationAnalyzer); + writer.WriteProperty(options, PropCategorizationFieldName, value.CategorizationFieldName); + writer.WriteProperty(options, PropCategorizationFilters, value.CategorizationFilters); + writer.WriteProperty(options, PropDetectors, value.Detectors); + writer.WriteProperty(options, PropInfluencers, value.Influencers, typeof(FieldsMarker)); + writer.WriteProperty(options, PropLatency, value.Latency); + writer.WriteProperty(options, PropModelPruneWindow, value.ModelPruneWindow); + writer.WriteProperty(options, PropMultivariateByFields, value.MultivariateByFields); + writer.WriteProperty(options, PropPerPartitionCategorization, value.PerPartitionCategorization); + writer.WriteProperty(options, PropSummaryCountFieldName, value.SummaryCountFieldName); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AnalysisConfigConverter))] public sealed partial class AnalysisConfig { /// @@ -35,7 +170,6 @@ public sealed partial class AnalysisConfig /// whole number of buckets in one day. If the anomaly detection job uses a datafeed with aggregations, this value must also be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("bucket_span")] public Elastic.Clients.Elasticsearch.Serverless.Duration? BucketSpan { get; set; } /// @@ -43,7 +177,6 @@ public sealed partial class AnalysisConfig /// If categorization_field_name is specified, you can also define the analyzer that is used to interpret the categorization field. This property cannot be used at the same time as categorization_filters. The categorization analyzer specifies how the categorization_field is interpreted by the categorization process. The categorization_analyzer field can be specified either as a string or as an object. If it is a string, it must refer to a built-in analyzer or one added by another plugin. /// /// - [JsonInclude, JsonPropertyName("categorization_analyzer")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.CategorizationAnalyzer? CategorizationAnalyzer { get; set; } /// @@ -51,7 +184,6 @@ public sealed partial class AnalysisConfig /// If this property is specified, the values of the specified field will be categorized. The resulting categories must be used in a detector by setting by_field_name, over_field_name, or partition_field_name to the keyword mlcategory. /// /// - [JsonInclude, JsonPropertyName("categorization_field_name")] public Elastic.Clients.Elasticsearch.Serverless.Field? CategorizationFieldName { get; set; } /// @@ -59,7 +191,6 @@ public sealed partial class AnalysisConfig /// If categorization_field_name is specified, you can also define optional filters. This property expects an array of regular expressions. The expressions are used to filter out matching sequences from the categorization field values. You can use this functionality to fine tune the categorization by excluding sequences from consideration when categories are defined. For example, you can exclude SQL statements that appear in your log files. This property cannot be used at the same time as categorization_analyzer. If you only want to define simple regular expression filters that are applied prior to tokenization, setting this property is the easiest method. If you also want to customize the tokenizer or post-tokenization filtering, use the categorization_analyzer property instead and include the filters as pattern_replace character filters. The effect is exactly the same. /// /// - [JsonInclude, JsonPropertyName("categorization_filters")] public ICollection? CategorizationFilters { get; set; } /// @@ -67,7 +198,6 @@ public sealed partial class AnalysisConfig /// Detector configuration objects specify which data fields a job analyzes. They also specify which analytical functions are used. You can specify multiple detectors for a job. If the detectors array does not contain at least one detector, no analysis can occur and an error is returned. /// /// - [JsonInclude, JsonPropertyName("detectors")] public ICollection Detectors { get; set; } /// @@ -75,8 +205,6 @@ public sealed partial class AnalysisConfig /// A comma separated list of influencer field names. Typically these can be the by, over, or partition fields that are used in the detector configuration. You might also want to use a field name that is not specifically named in a detector, but is available as part of the input data. When you use multiple detectors, the use of influencers is recommended as it aggregates results for each influencer entity. /// /// - [JsonInclude, JsonPropertyName("influencers")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Influencers { get; set; } /// @@ -84,7 +212,6 @@ public sealed partial class AnalysisConfig /// The size of the window in which to expect data that is out of time order. If you specify a non-zero value, it must be greater than or equal to one second. NOTE: Latency is applicable only when you send data by using the post data API. /// /// - [JsonInclude, JsonPropertyName("latency")] public Elastic.Clients.Elasticsearch.Serverless.Duration? Latency { get; set; } /// @@ -92,7 +219,6 @@ public sealed partial class AnalysisConfig /// Advanced configuration option. Affects the pruning of models that have not been updated for the given time duration. The value must be set to a multiple of the bucket_span. If set too low, important information may be removed from the model. For jobs created in 8.1 and later, the default value is the greater of 30d or 20 times bucket_span. /// /// - [JsonInclude, JsonPropertyName("model_prune_window")] public Elastic.Clients.Elasticsearch.Serverless.Duration? ModelPruneWindow { get; set; } /// @@ -100,7 +226,6 @@ public sealed partial class AnalysisConfig /// This functionality is reserved for internal use. It is not supported for use in customer environments and is not subject to the support SLA of official GA features. If set to true, the analysis will automatically find correlations between metrics for a given by field value and report anomalies when those correlations cease to hold. For example, suppose CPU and memory usage on host A is usually highly correlated with the same metrics on host B. Perhaps this correlation occurs because they are running a load-balanced application. If you enable this property, anomalies will be reported when, for example, CPU usage on host A is high and the value of CPU usage on host B is low. That is to say, you’ll see an anomaly when the CPU of host A is unusual given the CPU of host B. To use the multivariate_by_fields property, you must also specify by_field_name in your detector. /// /// - [JsonInclude, JsonPropertyName("multivariate_by_fields")] public bool? MultivariateByFields { get; set; } /// @@ -108,7 +233,6 @@ public sealed partial class AnalysisConfig /// Settings related to how categorization interacts with partition fields. /// /// - [JsonInclude, JsonPropertyName("per_partition_categorization")] public Elastic.Clients.Elasticsearch.Serverless.MachineLearning.PerPartitionCategorization? PerPartitionCategorization { get; set; } /// @@ -116,7 +240,6 @@ public sealed partial class AnalysisConfig /// If this property is specified, the data that is fed to the job is expected to be pre-summarized. This property value is the name of the field that contains the count of raw data points that have been summarized. The same summary_count_field_name applies to all detectors in the job. NOTE: The summary_count_field_name property cannot be used with the metric function. /// /// - [JsonInclude, JsonPropertyName("summary_count_field_name")] public Elastic.Clients.Elasticsearch.Serverless.Field? SummaryCountFieldName { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Datafeed.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Datafeed.g.cs index 2b8886a2e00..048956944d9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Datafeed.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Datafeed.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,137 +28,187 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; -internal sealed partial class DatafeedConverter : JsonConverter +internal sealed partial class DatafeedConverter : System.Text.Json.Serialization.JsonConverter { - public override Datafeed Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndexes = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override Datafeed Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? aggregations = default; - Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DatafeedAuthorization? authorization = default; - Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ChunkingConfig? chunkingConfig = default; - string datafeedId = default; - Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DelayedDataCheckConfig delayedDataCheckConfig = default; - Elastic.Clients.Elasticsearch.Serverless.Duration? frequency = default; - IReadOnlyCollection? indexes = default; - IReadOnlyCollection indices = default; - Elastic.Clients.Elasticsearch.Serverless.IndicesOptions? indicesOptions = default; - string jobId = default; - int? maxEmptySearches = default; - Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query query = default; - Elastic.Clients.Elasticsearch.Serverless.Duration? queryDelay = default; - IReadOnlyDictionary? runtimeMappings = default; - IReadOnlyDictionary? scriptFields = default; - int? scrollSize = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propAuthorization = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDatafeedId = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty?> propIndexes = default; + LocalJsonProperty> propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "authorization") - { - authorization = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - chunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "datafeed_id") - { - datafeedId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - delayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexes") - { - indexes = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "indices") - { - indices = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "indices_options") - { - indicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - jobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - maxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - queryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - runtimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - scriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - scrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndexes.TryRead(ref reader, options, PropIndexes)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - return new Datafeed { Aggregations = aggregations, Authorization = authorization, ChunkingConfig = chunkingConfig, DatafeedId = datafeedId, DelayedDataCheckConfig = delayedDataCheckConfig, Frequency = frequency, Indexes = indexes, Indices = indices, IndicesOptions = indicesOptions, JobId = jobId, MaxEmptySearches = maxEmptySearches, Query = query, QueryDelay = queryDelay, RuntimeMappings = runtimeMappings, ScriptFields = scriptFields, ScrollSize = scrollSize }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Datafeed + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indexes = propIndexes.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; } - public override void Write(Utf8JsonWriter writer, Datafeed value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Datafeed value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'Datafeed' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndexes, value.Indexes); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DatafeedConfig.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DatafeedConfig.g.cs index fabe268dcb2..039734032c6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DatafeedConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DatafeedConfig.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,194 +28,167 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; -internal sealed partial class DatafeedConfigConverter : JsonConverter +internal sealed partial class DatafeedConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override DatafeedConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override DatafeedConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DatafeedConfig(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAggregations = default; + LocalJsonProperty propChunkingConfig = default; + LocalJsonProperty propDatafeedId = default; + LocalJsonProperty propDelayedDataCheckConfig = default; + LocalJsonProperty propFrequency = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propIndicesOptions = default; + LocalJsonProperty propJobId = default; + LocalJsonProperty propMaxEmptySearches = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryDelay = default; + LocalJsonProperty?> propRuntimeMappings = default; + LocalJsonProperty?> propScriptFields = default; + LocalJsonProperty propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "datafeed_id") - { - variant.DatafeedId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DatafeedConfig value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.DatafeedId is not null) - { - writer.WritePropertyName("datafeed_id"); - JsonSerializer.Serialize(writer, value.DatafeedId, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatafeedConfig { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatafeedConfig value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs index e6b6480fc24..46d74d41e9a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal DataframeAnalysis(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeAnalysis() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeAnalysis Classification(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisClassification dataframeAnalysisClassification) => new DataframeAnalysis("classification", dataframeAnalysisClassification); public static DataframeAnalysis OutlierDetection(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisOutlierDetection dataframeAnalysisOutlierDetection) => new DataframeAnalysis("outlier_detection", dataframeAnalysisOutlierDetection); @@ -63,77 +68,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeAnalysisConverter : JsonConverter +internal sealed partial class DataframeAnalysisConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysis Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeAnalysis Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeAnalysis' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeAnalysis(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysis { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeAnalysis value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysis value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisClassification?)value.Variant); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisOutlierDetection?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeAnalysis)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs index c4ec45eaae3..c61237b0f5c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,56 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class DataframeAnalysisAnalyzedFieldsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropExcludes = System.Text.Json.JsonEncodedText.Encode("excludes"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes = System.Text.Json.JsonEncodedText.Encode("includes"); + + public override DataframeAnalysisAnalyzedFields Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue>(options); + return new DataframeAnalysisAnalyzedFields { Includes = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propExcludes = default; + LocalJsonProperty> propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExcludes.TryRead(ref reader, options, PropExcludes)) + { + continue; + } + + if (propIncludes.TryRead(ref reader, options, PropIncludes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisAnalyzedFields + { + Excludes = propExcludes.Value +, + Includes = propIncludes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisAnalyzedFields value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExcludes, value.Excludes); + writer.WriteProperty(options, PropIncludes, value.Includes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataframeAnalysisAnalyzedFieldsConverter))] public sealed partial class DataframeAnalysisAnalyzedFields { /// @@ -34,7 +85,6 @@ public sealed partial class DataframeAnalysisAnalyzedFields /// An array of strings that defines the fields that will be included in the analysis. /// /// - [JsonInclude, JsonPropertyName("excludes")] public ICollection Excludes { get; set; } /// @@ -42,7 +92,6 @@ public sealed partial class DataframeAnalysisAnalyzedFields /// An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically. /// /// - [JsonInclude, JsonPropertyName("includes")] public ICollection Includes { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs index 812e24662e2..533a32dce6f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,262 +28,226 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; -internal sealed partial class DataframeAnalysisClassificationConverter : JsonConverter +internal sealed partial class DataframeAnalysisClassificationConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisClassification Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAlpha = System.Text.Json.JsonEncodedText.Encode("alpha"); + private static readonly System.Text.Json.JsonEncodedText PropClassAssignmentObjective = System.Text.Json.JsonEncodedText.Encode("class_assignment_objective"); + private static readonly System.Text.Json.JsonEncodedText PropDependentVariable = System.Text.Json.JsonEncodedText.Encode("dependent_variable"); + private static readonly System.Text.Json.JsonEncodedText PropDownsampleFactor = System.Text.Json.JsonEncodedText.Encode("downsample_factor"); + private static readonly System.Text.Json.JsonEncodedText PropEarlyStoppingEnabled = System.Text.Json.JsonEncodedText.Encode("early_stopping_enabled"); + private static readonly System.Text.Json.JsonEncodedText PropEta = System.Text.Json.JsonEncodedText.Encode("eta"); + private static readonly System.Text.Json.JsonEncodedText PropEtaGrowthRatePerTree = System.Text.Json.JsonEncodedText.Encode("eta_growth_rate_per_tree"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureBagFraction = System.Text.Json.JsonEncodedText.Encode("feature_bag_fraction"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureProcessors = System.Text.Json.JsonEncodedText.Encode("feature_processors"); + private static readonly System.Text.Json.JsonEncodedText PropGamma = System.Text.Json.JsonEncodedText.Encode("gamma"); + private static readonly System.Text.Json.JsonEncodedText PropLambda = System.Text.Json.JsonEncodedText.Encode("lambda"); + private static readonly System.Text.Json.JsonEncodedText PropMaxOptimizationRoundsPerHyperparameter = System.Text.Json.JsonEncodedText.Encode("max_optimization_rounds_per_hyperparameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees = System.Text.Json.JsonEncodedText.Encode("max_trees"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees1 = System.Text.Json.JsonEncodedText.Encode("maximum_number_trees"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopClasses = System.Text.Json.JsonEncodedText.Encode("num_top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopFeatureImportanceValues = System.Text.Json.JsonEncodedText.Encode("num_top_feature_importance_values"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionFieldName = System.Text.Json.JsonEncodedText.Encode("prediction_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropRandomizeSeed = System.Text.Json.JsonEncodedText.Encode("randomize_seed"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthLimit = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthTolerance = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_tolerance"); + private static readonly System.Text.Json.JsonEncodedText PropTrainingPercent = System.Text.Json.JsonEncodedText.Encode("training_percent"); + + public override DataframeAnalysisClassification Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DataframeAnalysisClassification(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAlpha = default; + LocalJsonProperty propClassAssignmentObjective = default; + LocalJsonProperty propDependentVariable = default; + LocalJsonProperty propDownsampleFactor = default; + LocalJsonProperty propEarlyStoppingEnabled = default; + LocalJsonProperty propEta = default; + LocalJsonProperty propEtaGrowthRatePerTree = default; + LocalJsonProperty propFeatureBagFraction = default; + LocalJsonProperty?> propFeatureProcessors = default; + LocalJsonProperty propGamma = default; + LocalJsonProperty propLambda = default; + LocalJsonProperty propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonProperty propMaxTrees = default; + LocalJsonProperty propNumTopClasses = default; + LocalJsonProperty propNumTopFeatureImportanceValues = default; + LocalJsonProperty propPredictionFieldName = default; + LocalJsonProperty propRandomizeSeed = default; + LocalJsonProperty propSoftTreeDepthLimit = default; + LocalJsonProperty propSoftTreeDepthTolerance = default; + LocalJsonProperty propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryRead(ref reader, options, PropAlpha)) { - var property = reader.GetString(); - if (property == "alpha") - { - variant.Alpha = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "class_assignment_objective") - { - variant.ClassAssignmentObjective = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "dependent_variable") - { - variant.DependentVariable = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "downsample_factor") - { - variant.DownsampleFactor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "early_stopping_enabled") - { - variant.EarlyStoppingEnabled = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta") - { - variant.Eta = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta_growth_rate_per_tree") - { - variant.EtaGrowthRatePerTree = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_bag_fraction") - { - variant.FeatureBagFraction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_processors") - { - variant.FeatureProcessors = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "gamma") - { - variant.Gamma = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lambda") - { - variant.Lambda = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_optimization_rounds_per_hyperparameter") - { - variant.MaxOptimizationRoundsPerHyperparameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_trees" || property == "maximum_number_trees") - { - variant.MaxTrees = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_classes") - { - variant.NumTopClasses = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_feature_importance_values") - { - variant.NumTopFeatureImportanceValues = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prediction_field_name") - { - variant.PredictionFieldName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "randomize_seed") - { - variant.RandomizeSeed = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_limit") - { - variant.SoftTreeDepthLimit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_tolerance") - { - variant.SoftTreeDepthTolerance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "training_percent") - { - variant.TrainingPercent = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propClassAssignmentObjective.TryRead(ref reader, options, PropClassAssignmentObjective)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisClassification value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Alpha.HasValue) - { - writer.WritePropertyName("alpha"); - writer.WriteNumberValue(value.Alpha.Value); - } + if (propDependentVariable.TryRead(ref reader, options, PropDependentVariable)) + { + continue; + } - if (!string.IsNullOrEmpty(value.ClassAssignmentObjective)) - { - writer.WritePropertyName("class_assignment_objective"); - writer.WriteStringValue(value.ClassAssignmentObjective); - } + if (propDownsampleFactor.TryRead(ref reader, options, PropDownsampleFactor)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryRead(ref reader, options, PropEarlyStoppingEnabled)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryRead(ref reader, options, PropEta)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryRead(ref reader, options, PropEtaGrowthRatePerTree)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryRead(ref reader, options, PropFeatureBagFraction)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryRead(ref reader, options, PropFeatureProcessors)) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryRead(ref reader, options, PropGamma)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryRead(ref reader, options, PropLambda)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryRead(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryRead(ref reader, options, PropMaxTrees) || propMaxTrees.TryRead(ref reader, options, PropMaxTrees1)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopClasses.TryRead(ref reader, options, PropNumTopClasses)) + { + continue; + } - if (value.NumTopClasses.HasValue) - { - writer.WritePropertyName("num_top_classes"); - writer.WriteNumberValue(value.NumTopClasses.Value); - } + if (propNumTopFeatureImportanceValues.TryRead(ref reader, options, PropNumTopFeatureImportanceValues)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryRead(ref reader, options, PropPredictionFieldName)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryRead(ref reader, options, PropRandomizeSeed)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryRead(ref reader, options, PropSoftTreeDepthLimit)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryRead(ref reader, options, PropSoftTreeDepthTolerance)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryRead(ref reader, options, PropTrainingPercent)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisClassification + { + Alpha = propAlpha.Value +, + ClassAssignmentObjective = propClassAssignmentObjective.Value +, + DependentVariable = propDependentVariable.Value +, + DownsampleFactor = propDownsampleFactor.Value +, + EarlyStoppingEnabled = propEarlyStoppingEnabled.Value +, + Eta = propEta.Value +, + EtaGrowthRatePerTree = propEtaGrowthRatePerTree.Value +, + FeatureBagFraction = propFeatureBagFraction.Value +, + FeatureProcessors = propFeatureProcessors.Value +, + Gamma = propGamma.Value +, + Lambda = propLambda.Value +, + MaxOptimizationRoundsPerHyperparameter = propMaxOptimizationRoundsPerHyperparameter.Value +, + MaxTrees = propMaxTrees.Value +, + NumTopClasses = propNumTopClasses.Value +, + NumTopFeatureImportanceValues = propNumTopFeatureImportanceValues.Value +, + PredictionFieldName = propPredictionFieldName.Value +, + RandomizeSeed = propRandomizeSeed.Value +, + SoftTreeDepthLimit = propSoftTreeDepthLimit.Value +, + SoftTreeDepthTolerance = propSoftTreeDepthTolerance.Value +, + TrainingPercent = propTrainingPercent.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisClassification value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlpha, value.Alpha); + writer.WriteProperty(options, PropClassAssignmentObjective, value.ClassAssignmentObjective); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled); + writer.WriteProperty(options, PropEta, value.Eta); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors); + writer.WriteProperty(options, PropGamma, value.Gamma); + writer.WriteProperty(options, PropLambda, value.Lambda); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees); + writer.WriteProperty(options, PropNumTopClasses, value.NumTopClasses); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs index f9be4f3ac82..c464524d7ab 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal DataframeAnalysisFeatureProcessor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeAnalysisFeatureProcessor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeAnalysisFeatureProcessor FrequencyEncoding(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding dataframeAnalysisFeatureProcessorFrequencyEncoding) => new DataframeAnalysisFeatureProcessor("frequency_encoding", dataframeAnalysisFeatureProcessorFrequencyEncoding); public static DataframeAnalysisFeatureProcessor MultiEncoding(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding dataframeAnalysisFeatureProcessorMultiEncoding) => new DataframeAnalysisFeatureProcessor("multi_encoding", dataframeAnalysisFeatureProcessorMultiEncoding); @@ -65,97 +70,92 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeAnalysisFeatureProcessorConverter : JsonConverter +internal sealed partial class DataframeAnalysisFeatureProcessorConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisFeatureProcessor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantFrequencyEncoding = System.Text.Json.JsonEncodedText.Encode("frequency_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiEncoding = System.Text.Json.JsonEncodedText.Encode("multi_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantNGramEncoding = System.Text.Json.JsonEncodedText.Encode("n_gram_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantOneHotEncoding = System.Text.Json.JsonEncodedText.Encode("one_hot_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantTargetMeanEncoding = System.Text.Json.JsonEncodedText.Encode("target_mean_encoding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeAnalysisFeatureProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantFrequencyEncoding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_encoding") + if (reader.ValueTextEquals(VariantMultiEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "n_gram_encoding") + if (reader.ValueTextEquals(VariantNGramEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNGramEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "target_mean_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeAnalysisFeatureProcessor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeAnalysisFeatureProcessor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisFeatureProcessor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisFeatureProcessor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisFeatureProcessor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "frequency_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding)value.Variant, options); - break; - case "multi_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding)value.Variant, options); - break; - case "n_gram_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding?)value.Variant); + break; + case "multi_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding?)value.Variant); + break; + case "n_gram_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding?)value.Variant); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding?)value.Variant); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeAnalysisFeatureProcessor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs index d8aa08cedd4..394c4e977c8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,262 +28,226 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; -internal sealed partial class DataframeAnalysisRegressionConverter : JsonConverter +internal sealed partial class DataframeAnalysisRegressionConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisRegression Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAlpha = System.Text.Json.JsonEncodedText.Encode("alpha"); + private static readonly System.Text.Json.JsonEncodedText PropDependentVariable = System.Text.Json.JsonEncodedText.Encode("dependent_variable"); + private static readonly System.Text.Json.JsonEncodedText PropDownsampleFactor = System.Text.Json.JsonEncodedText.Encode("downsample_factor"); + private static readonly System.Text.Json.JsonEncodedText PropEarlyStoppingEnabled = System.Text.Json.JsonEncodedText.Encode("early_stopping_enabled"); + private static readonly System.Text.Json.JsonEncodedText PropEta = System.Text.Json.JsonEncodedText.Encode("eta"); + private static readonly System.Text.Json.JsonEncodedText PropEtaGrowthRatePerTree = System.Text.Json.JsonEncodedText.Encode("eta_growth_rate_per_tree"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureBagFraction = System.Text.Json.JsonEncodedText.Encode("feature_bag_fraction"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureProcessors = System.Text.Json.JsonEncodedText.Encode("feature_processors"); + private static readonly System.Text.Json.JsonEncodedText PropGamma = System.Text.Json.JsonEncodedText.Encode("gamma"); + private static readonly System.Text.Json.JsonEncodedText PropLambda = System.Text.Json.JsonEncodedText.Encode("lambda"); + private static readonly System.Text.Json.JsonEncodedText PropLossFunction = System.Text.Json.JsonEncodedText.Encode("loss_function"); + private static readonly System.Text.Json.JsonEncodedText PropLossFunctionParameter = System.Text.Json.JsonEncodedText.Encode("loss_function_parameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxOptimizationRoundsPerHyperparameter = System.Text.Json.JsonEncodedText.Encode("max_optimization_rounds_per_hyperparameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees = System.Text.Json.JsonEncodedText.Encode("max_trees"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees1 = System.Text.Json.JsonEncodedText.Encode("maximum_number_trees"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopFeatureImportanceValues = System.Text.Json.JsonEncodedText.Encode("num_top_feature_importance_values"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionFieldName = System.Text.Json.JsonEncodedText.Encode("prediction_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropRandomizeSeed = System.Text.Json.JsonEncodedText.Encode("randomize_seed"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthLimit = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthTolerance = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_tolerance"); + private static readonly System.Text.Json.JsonEncodedText PropTrainingPercent = System.Text.Json.JsonEncodedText.Encode("training_percent"); + + public override DataframeAnalysisRegression Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DataframeAnalysisRegression(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAlpha = default; + LocalJsonProperty propDependentVariable = default; + LocalJsonProperty propDownsampleFactor = default; + LocalJsonProperty propEarlyStoppingEnabled = default; + LocalJsonProperty propEta = default; + LocalJsonProperty propEtaGrowthRatePerTree = default; + LocalJsonProperty propFeatureBagFraction = default; + LocalJsonProperty?> propFeatureProcessors = default; + LocalJsonProperty propGamma = default; + LocalJsonProperty propLambda = default; + LocalJsonProperty propLossFunction = default; + LocalJsonProperty propLossFunctionParameter = default; + LocalJsonProperty propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonProperty propMaxTrees = default; + LocalJsonProperty propNumTopFeatureImportanceValues = default; + LocalJsonProperty propPredictionFieldName = default; + LocalJsonProperty propRandomizeSeed = default; + LocalJsonProperty propSoftTreeDepthLimit = default; + LocalJsonProperty propSoftTreeDepthTolerance = default; + LocalJsonProperty propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryRead(ref reader, options, PropAlpha)) { - var property = reader.GetString(); - if (property == "alpha") - { - variant.Alpha = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "dependent_variable") - { - variant.DependentVariable = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "downsample_factor") - { - variant.DownsampleFactor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "early_stopping_enabled") - { - variant.EarlyStoppingEnabled = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta") - { - variant.Eta = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta_growth_rate_per_tree") - { - variant.EtaGrowthRatePerTree = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_bag_fraction") - { - variant.FeatureBagFraction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_processors") - { - variant.FeatureProcessors = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "gamma") - { - variant.Gamma = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lambda") - { - variant.Lambda = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "loss_function") - { - variant.LossFunction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "loss_function_parameter") - { - variant.LossFunctionParameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_optimization_rounds_per_hyperparameter") - { - variant.MaxOptimizationRoundsPerHyperparameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_trees" || property == "maximum_number_trees") - { - variant.MaxTrees = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_feature_importance_values") - { - variant.NumTopFeatureImportanceValues = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prediction_field_name") - { - variant.PredictionFieldName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "randomize_seed") - { - variant.RandomizeSeed = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_limit") - { - variant.SoftTreeDepthLimit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_tolerance") - { - variant.SoftTreeDepthTolerance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "training_percent") - { - variant.TrainingPercent = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propDependentVariable.TryRead(ref reader, options, PropDependentVariable)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisRegression value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Alpha.HasValue) - { - writer.WritePropertyName("alpha"); - writer.WriteNumberValue(value.Alpha.Value); - } + if (propDownsampleFactor.TryRead(ref reader, options, PropDownsampleFactor)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryRead(ref reader, options, PropEarlyStoppingEnabled)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryRead(ref reader, options, PropEta)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryRead(ref reader, options, PropEtaGrowthRatePerTree)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryRead(ref reader, options, PropFeatureBagFraction)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryRead(ref reader, options, PropFeatureProcessors)) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryRead(ref reader, options, PropGamma)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryRead(ref reader, options, PropLambda)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propLossFunction.TryRead(ref reader, options, PropLossFunction)) + { + continue; + } - if (!string.IsNullOrEmpty(value.LossFunction)) - { - writer.WritePropertyName("loss_function"); - writer.WriteStringValue(value.LossFunction); - } + if (propLossFunctionParameter.TryRead(ref reader, options, PropLossFunctionParameter)) + { + continue; + } - if (value.LossFunctionParameter.HasValue) - { - writer.WritePropertyName("loss_function_parameter"); - writer.WriteNumberValue(value.LossFunctionParameter.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryRead(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryRead(ref reader, options, PropMaxTrees) || propMaxTrees.TryRead(ref reader, options, PropMaxTrees1)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopFeatureImportanceValues.TryRead(ref reader, options, PropNumTopFeatureImportanceValues)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryRead(ref reader, options, PropPredictionFieldName)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryRead(ref reader, options, PropRandomizeSeed)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryRead(ref reader, options, PropSoftTreeDepthLimit)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryRead(ref reader, options, PropSoftTreeDepthTolerance)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryRead(ref reader, options, PropTrainingPercent)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisRegression + { + Alpha = propAlpha.Value +, + DependentVariable = propDependentVariable.Value +, + DownsampleFactor = propDownsampleFactor.Value +, + EarlyStoppingEnabled = propEarlyStoppingEnabled.Value +, + Eta = propEta.Value +, + EtaGrowthRatePerTree = propEtaGrowthRatePerTree.Value +, + FeatureBagFraction = propFeatureBagFraction.Value +, + FeatureProcessors = propFeatureProcessors.Value +, + Gamma = propGamma.Value +, + Lambda = propLambda.Value +, + LossFunction = propLossFunction.Value +, + LossFunctionParameter = propLossFunctionParameter.Value +, + MaxOptimizationRoundsPerHyperparameter = propMaxOptimizationRoundsPerHyperparameter.Value +, + MaxTrees = propMaxTrees.Value +, + NumTopFeatureImportanceValues = propNumTopFeatureImportanceValues.Value +, + PredictionFieldName = propPredictionFieldName.Value +, + RandomizeSeed = propRandomizeSeed.Value +, + SoftTreeDepthLimit = propSoftTreeDepthLimit.Value +, + SoftTreeDepthTolerance = propSoftTreeDepthTolerance.Value +, + TrainingPercent = propTrainingPercent.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisRegression value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlpha, value.Alpha); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled); + writer.WriteProperty(options, PropEta, value.Eta); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors); + writer.WriteProperty(options, PropGamma, value.Gamma); + writer.WriteProperty(options, PropLambda, value.Lambda); + writer.WriteProperty(options, PropLossFunction, value.LossFunction); + writer.WriteProperty(options, PropLossFunctionParameter, value.LossFunctionParameter); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs index 1d558249276..6f4a9a4cbd1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal DataframeEvaluation(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeEvaluation() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeEvaluation Classification(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationClassification dataframeEvaluationClassification) => new DataframeEvaluation("classification", dataframeEvaluationClassification); public static DataframeEvaluation OutlierDetection(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationOutlierDetection dataframeEvaluationOutlierDetection) => new DataframeEvaluation("outlier_detection", dataframeEvaluationOutlierDetection); @@ -63,77 +68,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeEvaluationConverter : JsonConverter +internal sealed partial class DataframeEvaluationConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeEvaluation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeEvaluation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeEvaluation' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeEvaluation(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeEvaluation { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeEvaluation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeEvaluation value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationClassification?)value.Variant); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationOutlierDetection?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.DataframeEvaluationRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeEvaluation)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs index a86e4468446..4294b6c6b56 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -44,12 +45,16 @@ internal InferenceConfigCreate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfigCreate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfigCreate Classification(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigCreate("classification", classificationInferenceOptions); public static InferenceConfigCreate FillMask(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceOptions fillMaskInferenceOptions) => new InferenceConfigCreate("fill_mask", fillMaskInferenceOptions); @@ -75,147 +80,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigCreateConverter : JsonConverter +internal sealed partial class InferenceConfigCreateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfigCreate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantFillMask = System.Text.Json.JsonEncodedText.Encode("fill_mask"); + private static readonly System.Text.Json.JsonEncodedText VariantNer = System.Text.Json.JsonEncodedText.Encode("ner"); + private static readonly System.Text.Json.JsonEncodedText VariantPassThrough = System.Text.Json.JsonEncodedText.Encode("pass_through"); + private static readonly System.Text.Json.JsonEncodedText VariantQuestionAnswering = System.Text.Json.JsonEncodedText.Encode("question_answering"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + private static readonly System.Text.Json.JsonEncodedText VariantTextClassification = System.Text.Json.JsonEncodedText.Encode("text_classification"); + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText VariantTextExpansion = System.Text.Json.JsonEncodedText.Encode("text_expansion"); + private static readonly System.Text.Json.JsonEncodedText VariantZeroShotClassification = System.Text.Json.JsonEncodedText.Encode("zero_shot_classification"); + + public override InferenceConfigCreate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "zero_shot_classification") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfigCreate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfigCreate(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfigCreate { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfigCreate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfigCreate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NerInferenceOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.PassThroughInferenceOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.QuestionAnsweringInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextClassificationInferenceOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextEmbeddingInferenceOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextExpansionInferenceOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ZeroShotClassificationInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceOptions?)value.Variant); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NerInferenceOptions?)value.Variant); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.PassThroughInferenceOptions?)value.Variant); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.QuestionAnsweringInferenceOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextClassificationInferenceOptions?)value.Variant); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextEmbeddingInferenceOptions?)value.Variant); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextExpansionInferenceOptions?)value.Variant); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ZeroShotClassificationInferenceOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfigCreate)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs index 84a33ce0b83..020a381b7ba 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal InferenceConfigUpdate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfigUpdate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfigUpdate Classification(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigUpdate("classification", classificationInferenceOptions); public static InferenceConfigUpdate FillMask(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceUpdateOptions fillMaskInferenceUpdateOptions) => new InferenceConfigUpdate("fill_mask", fillMaskInferenceUpdateOptions); @@ -70,147 +75,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigUpdateConverter : JsonConverter +internal sealed partial class InferenceConfigUpdateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfigUpdate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantFillMask = System.Text.Json.JsonEncodedText.Encode("fill_mask"); + private static readonly System.Text.Json.JsonEncodedText VariantNer = System.Text.Json.JsonEncodedText.Encode("ner"); + private static readonly System.Text.Json.JsonEncodedText VariantPassThrough = System.Text.Json.JsonEncodedText.Encode("pass_through"); + private static readonly System.Text.Json.JsonEncodedText VariantQuestionAnswering = System.Text.Json.JsonEncodedText.Encode("question_answering"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + private static readonly System.Text.Json.JsonEncodedText VariantTextClassification = System.Text.Json.JsonEncodedText.Encode("text_classification"); + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText VariantTextExpansion = System.Text.Json.JsonEncodedText.Encode("text_expansion"); + private static readonly System.Text.Json.JsonEncodedText VariantZeroShotClassification = System.Text.Json.JsonEncodedText.Encode("zero_shot_classification"); + + public override InferenceConfigUpdate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "zero_shot_classification") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfigUpdate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfigUpdate(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfigUpdate { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfigUpdate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfigUpdate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceUpdateOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NerInferenceUpdateOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.PassThroughInferenceUpdateOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.QuestionAnsweringInferenceUpdateOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextClassificationInferenceUpdateOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextEmbeddingInferenceUpdateOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextExpansionInferenceUpdateOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ZeroShotClassificationInferenceUpdateOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FillMaskInferenceUpdateOptions?)value.Variant); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NerInferenceUpdateOptions?)value.Variant); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.PassThroughInferenceUpdateOptions?)value.Variant); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.QuestionAnsweringInferenceUpdateOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextClassificationInferenceUpdateOptions?)value.Variant); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextEmbeddingInferenceUpdateOptions?)value.Variant); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TextExpansionInferenceUpdateOptions?)value.Variant); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.ZeroShotClassificationInferenceUpdateOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfigUpdate)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs index 17adcb46d84..fec46366df1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,120 @@ namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning; +internal sealed partial class InferenceResponseResultConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEntities = System.Text.Json.JsonEncodedText.Encode("entities"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureImportance = System.Text.Json.JsonEncodedText.Encode("feature_importance"); + private static readonly System.Text.Json.JsonEncodedText PropIsTruncated = System.Text.Json.JsonEncodedText.Encode("is_truncated"); + private static readonly System.Text.Json.JsonEncodedText PropPredictedValue = System.Text.Json.JsonEncodedText.Encode("predicted_value"); + private static readonly System.Text.Json.JsonEncodedText PropPredictedValueSequence = System.Text.Json.JsonEncodedText.Encode("predicted_value_sequence"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionProbability = System.Text.Json.JsonEncodedText.Encode("prediction_probability"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionScore = System.Text.Json.JsonEncodedText.Encode("prediction_score"); + private static readonly System.Text.Json.JsonEncodedText PropTopClasses = System.Text.Json.JsonEncodedText.Encode("top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropWarning = System.Text.Json.JsonEncodedText.Encode("warning"); + + public override InferenceResponseResult Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propEntities = default; + LocalJsonProperty?> propFeatureImportance = default; + LocalJsonProperty propIsTruncated = default; + LocalJsonProperty?> propPredictedValue = default; + LocalJsonProperty propPredictedValueSequence = default; + LocalJsonProperty propPredictionProbability = default; + LocalJsonProperty propPredictionScore = default; + LocalJsonProperty?> propTopClasses = default; + LocalJsonProperty propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEntities.TryRead(ref reader, options, PropEntities)) + { + continue; + } + + if (propFeatureImportance.TryRead(ref reader, options, PropFeatureImportance)) + { + continue; + } + + if (propIsTruncated.TryRead(ref reader, options, PropIsTruncated)) + { + continue; + } + + if (propPredictedValue.TryRead(ref reader, options, PropPredictedValue, typeof(SingleOrManyMarker?, object>))) + { + continue; + } + + if (propPredictedValueSequence.TryRead(ref reader, options, PropPredictedValueSequence)) + { + continue; + } + + if (propPredictionProbability.TryRead(ref reader, options, PropPredictionProbability)) + { + continue; + } + + if (propPredictionScore.TryRead(ref reader, options, PropPredictionScore)) + { + continue; + } + + if (propTopClasses.TryRead(ref reader, options, PropTopClasses)) + { + continue; + } + + if (propWarning.TryRead(ref reader, options, PropWarning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceResponseResult + { + Entities = propEntities.Value +, + FeatureImportance = propFeatureImportance.Value +, + IsTruncated = propIsTruncated.Value +, + PredictedValue = propPredictedValue.Value +, + PredictedValueSequence = propPredictedValueSequence.Value +, + PredictionProbability = propPredictionProbability.Value +, + PredictionScore = propPredictionScore.Value +, + TopClasses = propTopClasses.Value +, + Warning = propWarning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceResponseResult value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEntities, value.Entities); + writer.WriteProperty(options, PropFeatureImportance, value.FeatureImportance); + writer.WriteProperty(options, PropIsTruncated, value.IsTruncated); + writer.WriteProperty(options, PropPredictedValue, value.PredictedValue, typeof(SingleOrManyMarker?, object>)); + writer.WriteProperty(options, PropPredictedValueSequence, value.PredictedValueSequence); + writer.WriteProperty(options, PropPredictionProbability, value.PredictionProbability); + writer.WriteProperty(options, PropPredictionScore, value.PredictionScore); + writer.WriteProperty(options, PropTopClasses, value.TopClasses); + writer.WriteProperty(options, PropWarning, value.Warning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferenceResponseResultConverter))] public sealed partial class InferenceResponseResult { /// @@ -34,7 +149,6 @@ public sealed partial class InferenceResponseResult /// If the model is trained for named entity recognition (NER) tasks, the response contains the recognized entities. /// /// - [JsonInclude, JsonPropertyName("entities")] public IReadOnlyCollection? Entities { get; init; } /// @@ -42,7 +156,6 @@ public sealed partial class InferenceResponseResult /// The feature importance for the inference results. Relevant only for classification or regression models /// /// - [JsonInclude, JsonPropertyName("feature_importance")] public IReadOnlyCollection? FeatureImportance { get; init; } /// @@ -51,7 +164,6 @@ public sealed partial class InferenceResponseResult /// is present only when it is true. /// /// - [JsonInclude, JsonPropertyName("is_truncated")] public bool? IsTruncated { get; init; } /// @@ -65,8 +177,6 @@ public sealed partial class InferenceResponseResult /// For classification models, it may be an integer, double, boolean or string depending on prediction type /// /// - [JsonInclude, JsonPropertyName("predicted_value")] - [SingleOrManyCollectionConverter(typeof(object))] public IReadOnlyCollection? PredictedValue { get; init; } /// @@ -76,7 +186,6 @@ public sealed partial class InferenceResponseResult /// Additionally /// /// - [JsonInclude, JsonPropertyName("predicted_value_sequence")] public string? PredictedValueSequence { get; init; } /// @@ -84,7 +193,6 @@ public sealed partial class InferenceResponseResult /// Specifies a probability for the predicted value. /// /// - [JsonInclude, JsonPropertyName("prediction_probability")] public double? PredictionProbability { get; init; } /// @@ -92,7 +200,6 @@ public sealed partial class InferenceResponseResult /// Specifies a confidence score for the predicted value. /// /// - [JsonInclude, JsonPropertyName("prediction_score")] public double? PredictionScore { get; init; } /// @@ -101,7 +208,6 @@ public sealed partial class InferenceResponseResult /// class entries. /// /// - [JsonInclude, JsonPropertyName("top_classes")] public IReadOnlyCollection? TopClasses { get; init; } /// @@ -109,6 +215,5 @@ public sealed partial class InferenceResponseResult /// If the request failed, the response contains the reason for the failure. /// /// - [JsonInclude, JsonPropertyName("warning")] public string? Warning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Preprocessor.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Preprocessor.g.cs index ffce803e061..7b680126ba5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Preprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/Preprocessor.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Preprocessor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Preprocessor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Preprocessor FrequencyEncoding(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FrequencyEncodingPreprocessor frequencyEncodingPreprocessor) => new Preprocessor("frequency_encoding", frequencyEncodingPreprocessor); public static Preprocessor OneHotEncoding(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.OneHotEncodingPreprocessor oneHotEncodingPreprocessor) => new Preprocessor("one_hot_encoding", oneHotEncodingPreprocessor); @@ -63,77 +68,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class PreprocessorConverter : JsonConverter +internal sealed partial class PreprocessorConverter : System.Text.Json.Serialization.JsonConverter { - public override Preprocessor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantFrequencyEncoding = System.Text.Json.JsonEncodedText.Encode("frequency_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantOneHotEncoding = System.Text.Json.JsonEncodedText.Encode("one_hot_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantTargetMeanEncoding = System.Text.Json.JsonEncodedText.Encode("target_mean_encoding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Preprocessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantFrequencyEncoding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "target_mean_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Preprocessor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Preprocessor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Preprocessor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Preprocessor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Preprocessor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "frequency_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FrequencyEncodingPreprocessor)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.OneHotEncodingPreprocessor)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TargetMeanEncodingPreprocessor)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.FrequencyEncodingPreprocessor?)value.Variant); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.OneHotEncodingPreprocessor?)value.Variant); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.TargetMeanEncodingPreprocessor?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Preprocessor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/TokenizationConfig.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/TokenizationConfig.g.cs index fb54aca32fc..df1204ccae3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/TokenizationConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/MachineLearning/TokenizationConfig.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -44,12 +45,16 @@ internal TokenizationConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal TokenizationConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static TokenizationConfig Bert(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert", nlpBertTokenizationConfig); public static TokenizationConfig BertJa(Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert_ja", nlpBertTokenizationConfig); @@ -69,87 +74,80 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class TokenizationConfigConverter : JsonConverter +internal sealed partial class TokenizationConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenizationConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantBert = System.Text.Json.JsonEncodedText.Encode("bert"); + private static readonly System.Text.Json.JsonEncodedText VariantBertJa = System.Text.Json.JsonEncodedText.Encode("bert_ja"); + private static readonly System.Text.Json.JsonEncodedText VariantMpnet = System.Text.Json.JsonEncodedText.Encode("mpnet"); + private static readonly System.Text.Json.JsonEncodedText VariantRoberta = System.Text.Json.JsonEncodedText.Encode("roberta"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override TokenizationConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantBert)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bert") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBert.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bert_ja") + if (reader.ValueTextEquals(VariantBertJa)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBertJa.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "mpnet") + if (reader.ValueTextEquals(VariantMpnet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMpnet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "roberta") + if (reader.ValueTextEquals(VariantRoberta)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRoberta.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'TokenizationConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new TokenizationConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TokenizationConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, TokenizationConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenizationConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "bert": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "bert_ja": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "mpnet": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "roberta": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpRobertaTokenizationConfig)value.Variant, options); - break; - } + case "": + break; + case "bert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "bert_ja": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "mpnet": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "roberta": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.MachineLearning.NlpRobertaTokenizationConfig?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(TokenizationConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BinaryProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BinaryProperty.g.cs index b28e2cb4305..2b2ed79c90a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BinaryProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BinaryProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,124 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class BinaryPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BinaryProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BinaryProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BinaryProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BinaryPropertyConverter))] public sealed partial class BinaryProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +153,10 @@ public sealed partial class BinaryProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "binary"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BooleanProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BooleanProperty.g.cs index 590190c8b1e..01ef30cff37 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BooleanProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/BooleanProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,167 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class BooleanPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BooleanProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFielddata = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BooleanProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fielddata = propFielddata.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BooleanProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BooleanPropertyConverter))] public sealed partial class BooleanProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,16 +196,11 @@ public sealed partial class BooleanProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public bool? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "boolean"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ByteNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ByteNumberProperty.g.cs index bc24858541b..aa429115100 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ByteNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ByteNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class ByteNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ByteNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ByteNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ByteNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ByteNumberPropertyConverter))] public sealed partial class ByteNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class ByteNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public byte? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "byte"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/CompletionProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/CompletionProperty.g.cs index 68c7d5053b5..e4b3fc1aed4 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/CompletionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/CompletionProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,187 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class CompletionPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMaxInputLength = System.Text.Json.JsonEncodedText.Encode("max_input_length"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropPreservePositionIncrements = System.Text.Json.JsonEncodedText.Encode("preserve_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropPreserveSeparators = System.Text.Json.JsonEncodedText.Encode("preserve_separators"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CompletionProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty?> propContexts = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propMaxInputLength = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propPreservePositionIncrements = default; + LocalJsonProperty propPreserveSeparators = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propSearchAnalyzer = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propContexts.TryRead(ref reader, options, PropContexts)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMaxInputLength.TryRead(ref reader, options, PropMaxInputLength)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPreservePositionIncrements.TryRead(ref reader, options, PropPreservePositionIncrements)) + { + continue; + } + + if (propPreserveSeparators.TryRead(ref reader, options, PropPreserveSeparators)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionProperty + { + Analyzer = propAnalyzer.Value +, + Contexts = propContexts.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + MaxInputLength = propMaxInputLength.Value +, + Meta = propMeta.Value +, + PreservePositionIncrements = propPreservePositionIncrements.Value +, + PreserveSeparators = propPreserveSeparators.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropContexts, value.Contexts); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMaxInputLength, value.MaxInputLength); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPreservePositionIncrements, value.PreservePositionIncrements); + writer.WriteProperty(options, PropPreserveSeparators, value.PreserveSeparators); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionPropertyConverter))] public sealed partial class CompletionProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("contexts")] public ICollection? Contexts { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("max_input_length")] public int? MaxInputLength { get; set; } /// @@ -52,20 +216,13 @@ public sealed partial class CompletionProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("preserve_position_increments")] public bool? PreservePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("preserve_separators")] public bool? PreserveSeparators { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "completion"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateNanosProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateNanosProperty.g.cs index 9cc89e12a5b..457b33346d1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateNanosProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateNanosProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,188 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DateNanosPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateNanosProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propPrecisionStep = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateNanosProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateNanosProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateNanosPropertyConverter))] public sealed partial class DateNanosProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,18 +217,12 @@ public sealed partial class DateNanosProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public DateTimeOffset? NullValue { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date_nanos"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateProperty.g.cs index 01298193afb..e0232e2542a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,30 +28,210 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DatePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropLocale = System.Text.Json.JsonEncodedText.Encode("locale"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFielddata = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propLocale = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propPrecisionStep = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propLocale.TryRead(ref reader, options, PropLocale)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fielddata = propFielddata.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Locale = propLocale.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropLocale, value.Locale); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DatePropertyConverter))] public sealed partial class DateProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("locale")] public string? Locale { get; set; } /// @@ -58,18 +239,12 @@ public sealed partial class DateProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public DateTimeOffset? NullValue { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateRangeProperty.g.cs index 98a8be7ae0d..87aa936cfbb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DateRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,168 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DateRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateRangePropertyConverter))] public sealed partial class DateRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,14 +197,10 @@ public sealed partial class DateRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleNumberProperty.g.cs index 1c50170dbfe..ba926366bf9 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DoubleNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DoubleNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DoubleNumberPropertyConverter))] public sealed partial class DoubleNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class DoubleNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "double"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleRangeProperty.g.cs index cd3a1dfc6c5..ff7a2aba327 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DoubleRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DoubleRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DoubleRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DoubleRangePropertyConverter))] public sealed partial class DoubleRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +186,10 @@ public sealed partial class DoubleRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "double_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicProperty.g.cs index c82eb82083c..289dd5d1b2a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,42 +28,356 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class DynamicPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPhrases = System.Text.Json.JsonEncodedText.Encode("index_phrases"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPrefixes = System.Text.Json.JsonEncodedText.Encode("index_prefixes"); + private static readonly System.Text.Json.JsonEncodedText PropLocale = System.Text.Json.JsonEncodedText.Encode("locale"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DynamicProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEagerGlobalOrdinals = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexOptions = default; + LocalJsonProperty propIndexPhrases = default; + LocalJsonProperty propIndexPrefixes = default; + LocalJsonProperty propLocale = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNorms = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propPositionIncrementGap = default; + LocalJsonProperty propPrecisionStep = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propSearchAnalyzer = default; + LocalJsonProperty propSearchQuoteAnalyzer = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propTermVector = default; + LocalJsonProperty propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propIndexPhrases.TryRead(ref reader, options, PropIndexPhrases)) + { + continue; + } + + if (propIndexPrefixes.TryRead(ref reader, options, PropIndexPrefixes)) + { + continue; + } + + if (propLocale.TryRead(ref reader, options, PropLocale)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DynamicProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + IndexPhrases = propIndexPhrases.Value +, + IndexPrefixes = propIndexPrefixes.Value +, + Locale = propLocale.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes); + writer.WriteProperty(options, PropLocale, value.Locale); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DynamicPropertyConverter))] public sealed partial class DynamicProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } - [JsonInclude, JsonPropertyName("locale")] public string? Locale { get; set; } /// @@ -70,34 +385,20 @@ public sealed partial class DynamicProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public Elastic.Clients.Elasticsearch.Serverless.FieldValue? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "{dynamic_type}"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicTemplate.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicTemplate.g.cs index 84661cf4461..e999ebf8852 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/DynamicTemplate.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal DynamicTemplate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DynamicTemplate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DynamicTemplate Mapping(Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty property) => new DynamicTemplate("mapping", property); public static DynamicTemplate Runtime(Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty property) => new DynamicTemplate("runtime", property); @@ -77,167 +82,131 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DynamicTemplateConverter : JsonConverter +internal sealed partial class DynamicTemplateConverter : System.Text.Json.Serialization.JsonConverter { - public override DynamicTemplate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText PropMatchMappingType = System.Text.Json.JsonEncodedText.Encode("match_mapping_type"); + private static readonly System.Text.Json.JsonEncodedText PropMatchPattern = System.Text.Json.JsonEncodedText.Encode("match_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropPathMatch = System.Text.Json.JsonEncodedText.Encode("path_match"); + private static readonly System.Text.Json.JsonEncodedText PropPathUnmatch = System.Text.Json.JsonEncodedText.Encode("path_unmatch"); + private static readonly System.Text.Json.JsonEncodedText PropUnmatch = System.Text.Json.JsonEncodedText.Encode("unmatch"); + private static readonly System.Text.Json.JsonEncodedText PropUnmatchMappingType = System.Text.Json.JsonEncodedText.Encode("unmatch_mapping_type"); + private static readonly System.Text.Json.JsonEncodedText VariantMapping = System.Text.Json.JsonEncodedText.Encode("mapping"); + private static readonly System.Text.Json.JsonEncodedText VariantRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + + public override DynamicTemplate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - ICollection? matchValue = default; - ICollection? matchMappingTypeValue = default; - Elastic.Clients.Elasticsearch.Serverless.Mapping.MatchType? matchPatternValue = default; - ICollection? pathMatchValue = default; - ICollection? pathUnmatchValue = default; - ICollection? unmatchValue = default; - ICollection? unmatchMappingTypeValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propMatch = default; + LocalJsonProperty?> propMatchMappingType = default; + LocalJsonProperty propMatchPattern = default; + LocalJsonProperty?> propPathMatch = default; + LocalJsonProperty?> propPathUnmatch = default; + LocalJsonProperty?> propUnmatch = default; + LocalJsonProperty?> propUnmatchMappingType = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "match") + if (propMatch.TryRead(ref reader, options, PropMatch, typeof(SingleOrManyMarker?, string>))) { - matchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_mapping_type") + if (propMatchMappingType.TryRead(ref reader, options, PropMatchMappingType, typeof(SingleOrManyMarker?, string>))) { - matchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_pattern") + if (propMatchPattern.TryRead(ref reader, options, PropMatchPattern)) { - matchPatternValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "path_match") + if (propPathMatch.TryRead(ref reader, options, PropPathMatch, typeof(SingleOrManyMarker?, string>))) { - pathMatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "path_unmatch") + if (propPathUnmatch.TryRead(ref reader, options, PropPathUnmatch, typeof(SingleOrManyMarker?, string>))) { - pathUnmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch") + if (propUnmatch.TryRead(ref reader, options, PropUnmatch, typeof(SingleOrManyMarker?, string>))) { - unmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch_mapping_type") + if (propUnmatchMappingType.TryRead(ref reader, options, PropUnmatchMappingType, typeof(SingleOrManyMarker?, string>))) { - unmatchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "mapping") + if (reader.ValueTextEquals(VariantMapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "runtime") + if (reader.ValueTextEquals(VariantRuntime)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRuntime.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DynamicTemplate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DynamicTemplate(variantNameValue, variantValue); - result.Match = matchValue; - result.MatchMappingType = matchMappingTypeValue; - result.MatchPattern = matchPatternValue; - result.PathMatch = pathMatchValue; - result.PathUnmatch = pathUnmatchValue; - result.Unmatch = unmatchValue; - result.UnmatchMappingType = unmatchMappingTypeValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DynamicTemplate + { + VariantType = variantType, + Variant = variant, + Match = propMatch.Value +, + MatchMappingType = propMatchMappingType.Value +, + MatchPattern = propMatchPattern.Value +, + PathMatch = propPathMatch.Value +, + PathUnmatch = propPathUnmatch.Value +, + Unmatch = propUnmatch.Value +, + UnmatchMappingType = propUnmatchMappingType.Value + }; } - public override void Write(Utf8JsonWriter writer, DynamicTemplate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicTemplate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Match is not null) - { - writer.WritePropertyName("match"); - SingleOrManySerializationHelper.Serialize(value.Match, writer, options); - } - - if (value.MatchMappingType is not null) + switch (value.VariantType) { - writer.WritePropertyName("match_mapping_type"); - SingleOrManySerializationHelper.Serialize(value.MatchMappingType, writer, options); - } - - if (value.MatchPattern is not null) - { - writer.WritePropertyName("match_pattern"); - JsonSerializer.Serialize(writer, value.MatchPattern, options); - } - - if (value.PathMatch is not null) - { - writer.WritePropertyName("path_match"); - SingleOrManySerializationHelper.Serialize(value.PathMatch, writer, options); - } - - if (value.PathUnmatch is not null) - { - writer.WritePropertyName("path_unmatch"); - SingleOrManySerializationHelper.Serialize(value.PathUnmatch, writer, options); - } - - if (value.Unmatch is not null) - { - writer.WritePropertyName("unmatch"); - SingleOrManySerializationHelper.Serialize(value.Unmatch, writer, options); - } - - if (value.UnmatchMappingType is not null) - { - writer.WritePropertyName("unmatch_mapping_type"); - SingleOrManySerializationHelper.Serialize(value.UnmatchMappingType, writer, options); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "mapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty)value.Variant, options); - break; - case "runtime": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty)value.Variant, options); - break; - } + case "": + break; + case "mapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty?)value.Variant); + break; + case "runtime": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IProperty?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DynamicTemplate)}'."); } + writer.WriteProperty(options, PropMatch, value.Match, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMatchMappingType, value.MatchMappingType, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMatchPattern, value.MatchPattern); + writer.WriteProperty(options, PropPathMatch, value.PathMatch, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropPathUnmatch, value.PathUnmatch, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnmatch, value.Unmatch, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnmatchMappingType, value.UnmatchMappingType, typeof(SingleOrManyMarker?, string>)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatNumberProperty.g.cs index 209758f348f..942ecd5e5da 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class FloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FloatNumberPropertyConverter))] public sealed partial class FloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class FloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public float? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "float"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatRangeProperty.g.cs index 18e6057c59c..d06c120ad34 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/FloatRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class FloatRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FloatRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FloatRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FloatRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FloatRangePropertyConverter))] public sealed partial class FloatRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +186,10 @@ public sealed partial class FloatRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "float_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoPointProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoPointProperty.g.cs index 048ce25f474..e7fe90b0fcf 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoPointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoPointProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,187 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class GeoPointPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GeoPointProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIgnoreZValue = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoPointProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoPointProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoPointPropertyConverter))] public sealed partial class GeoPointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,20 +216,13 @@ public sealed partial class GeoPointProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public Elastic.Clients.Elasticsearch.Serverless.GeoLocation? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "geo_point"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoShapeProperty.g.cs index 30917b79567..3566c63ebf2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/GeoShapeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,167 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class GeoShapePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropOrientation = System.Text.Json.JsonEncodedText.Encode("orientation"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropStrategy = System.Text.Json.JsonEncodedText.Encode("strategy"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GeoShapeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIgnoreZValue = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propOrientation = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propStrategy = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propOrientation.TryRead(ref reader, options, PropOrientation)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propStrategy.TryRead(ref reader, options, PropStrategy)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoShapeProperty + { + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + Orientation = propOrientation.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + Strategy = propStrategy.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropOrientation, value.Orientation); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropStrategy, value.Strategy); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// The geo_shape data type facilitates the indexing of and searching with arbitrary geo shapes such as rectangles @@ -34,24 +196,16 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(GeoShapePropertyConverter))] public sealed partial class GeoShapeProperty : IProperty { - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -59,18 +213,12 @@ public sealed partial class GeoShapeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("orientation")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("strategy")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoStrategy? Strategy { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "geo_shape"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs index 2ec7faa6a78..2edc82cf8d0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class HalfFloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HalfFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HalfFloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HalfFloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HalfFloatNumberPropertyConverter))] public sealed partial class HalfFloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public float? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "half_float"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IcuCollationProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IcuCollationProperty.g.cs index 21424b05c95..04f284e79af 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IcuCollationProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IcuCollationProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,30 +28,290 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class IcuCollationPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlternate = System.Text.Json.JsonEncodedText.Encode("alternate"); + private static readonly System.Text.Json.JsonEncodedText PropCaseFirst = System.Text.Json.JsonEncodedText.Encode("case_first"); + private static readonly System.Text.Json.JsonEncodedText PropCaseLevel = System.Text.Json.JsonEncodedText.Encode("case_level"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropCountry = System.Text.Json.JsonEncodedText.Encode("country"); + private static readonly System.Text.Json.JsonEncodedText PropDecomposition = System.Text.Json.JsonEncodedText.Encode("decomposition"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHiraganaQuaternaryMode = System.Text.Json.JsonEncodedText.Encode("hiragana_quaternary_mode"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropNumeric = System.Text.Json.JsonEncodedText.Encode("numeric"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropStrength = System.Text.Json.JsonEncodedText.Encode("strength"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVariableTop = System.Text.Json.JsonEncodedText.Encode("variable_top"); + private static readonly System.Text.Json.JsonEncodedText PropVariant = System.Text.Json.JsonEncodedText.Encode("variant"); + + public override IcuCollationProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAlternate = default; + LocalJsonProperty propCaseFirst = default; + LocalJsonProperty propCaseLevel = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propCountry = default; + LocalJsonProperty propDecomposition = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propHiraganaQuaternaryMode = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexOptions = default; + LocalJsonProperty propLanguage = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNorms = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propNumeric = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propRules = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propStrength = default; + LocalJsonProperty propVariableTop = default; + LocalJsonProperty propVariant = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlternate.TryRead(ref reader, options, PropAlternate)) + { + continue; + } + + if (propCaseFirst.TryRead(ref reader, options, PropCaseFirst)) + { + continue; + } + + if (propCaseLevel.TryRead(ref reader, options, PropCaseLevel)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propCountry.TryRead(ref reader, options, PropCountry)) + { + continue; + } + + if (propDecomposition.TryRead(ref reader, options, PropDecomposition)) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHiraganaQuaternaryMode.TryRead(ref reader, options, PropHiraganaQuaternaryMode)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propNumeric.TryRead(ref reader, options, PropNumeric)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propRules.TryRead(ref reader, options, PropRules)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propStrength.TryRead(ref reader, options, PropStrength)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVariableTop.TryRead(ref reader, options, PropVariableTop)) + { + continue; + } + + if (propVariant.TryRead(ref reader, options, PropVariant)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IcuCollationProperty + { + Alternate = propAlternate.Value +, + CaseFirst = propCaseFirst.Value +, + CaseLevel = propCaseLevel.Value +, + CopyTo = propCopyTo.Value +, + Country = propCountry.Value +, + Decomposition = propDecomposition.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + HiraganaQuaternaryMode = propHiraganaQuaternaryMode.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + Language = propLanguage.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + Numeric = propNumeric.Value +, + Properties = propProperties.Value +, + Rules = propRules.Value +, + Store = propStore.Value +, + Strength = propStrength.Value +, + VariableTop = propVariableTop.Value +, + Variant = propVariant.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlternate, value.Alternate); + writer.WriteProperty(options, PropCaseFirst, value.CaseFirst); + writer.WriteProperty(options, PropCaseLevel, value.CaseLevel); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropCountry, value.Country); + writer.WriteProperty(options, PropDecomposition, value.Decomposition); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHiraganaQuaternaryMode, value.HiraganaQuaternaryMode); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropNumeric, value.Numeric); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropRules, value.Rules); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropStrength, value.Strength); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVariableTop, value.VariableTop); + writer.WriteProperty(options, PropVariant, value.Variant); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IcuCollationPropertyConverter))] public sealed partial class IcuCollationProperty : IProperty { - [JsonInclude, JsonPropertyName("alternate")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationAlternate? Alternate { get; set; } - [JsonInclude, JsonPropertyName("case_first")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationCaseFirst? CaseFirst { get; set; } - [JsonInclude, JsonPropertyName("case_level")] public bool? CaseLevel { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("country")] public string? Country { get; set; } - [JsonInclude, JsonPropertyName("decomposition")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationDecomposition? Decomposition { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("hiragana_quaternary_mode")] public bool? HiraganaQuaternaryMode { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -58,11 +319,8 @@ public sealed partial class IcuCollationProperty : IProperty /// Should the field be searchable? /// /// - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("language")] public string? Language { get; set; } /// @@ -70,9 +328,7 @@ public sealed partial class IcuCollationProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } /// @@ -80,25 +336,16 @@ public sealed partial class IcuCollationProperty : IProperty /// Accepts a string value which is substituted for any explicit null values. Defaults to null, which means the field is treated as missing. /// /// - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("numeric")] public bool? Numeric { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("rules")] public string? Rules { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("strength")] public Elastic.Clients.Elasticsearch.Serverless.Analysis.IcuCollationStrength? Strength { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "icu_collation_keyword"; - [JsonInclude, JsonPropertyName("variable_top")] public string? VariableTop { get; set; } - [JsonInclude, JsonPropertyName("variant")] public string? Variant { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerNumberProperty.g.cs index 508c776da51..19fa24ed105 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class IntegerNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IntegerNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntegerNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntegerNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IntegerNumberPropertyConverter))] public sealed partial class IntegerNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class IntegerNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public int? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "integer"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerRangeProperty.g.cs index 3f5480fa605..abb0e74a9c3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IntegerRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class IntegerRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IntegerRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntegerRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntegerRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IntegerRangePropertyConverter))] public sealed partial class IntegerRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +186,10 @@ public sealed partial class IntegerRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "integer_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpProperty.g.cs index adffb9e4746..d99e02d3147 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,187 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class IpPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IpProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IpPropertyConverter))] public sealed partial class IpProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,20 +216,13 @@ public sealed partial class IpProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "ip"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpRangeProperty.g.cs index e8bb6651899..cc9f28ea9c5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/IpRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class IpRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IpRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IpRangePropertyConverter))] public sealed partial class IpRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +186,10 @@ public sealed partial class IpRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "ip_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/KeywordProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/KeywordProperty.g.cs index 2d120c42c28..924211b413e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/KeywordProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/KeywordProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,238 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class KeywordPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNormalizer = System.Text.Json.JsonEncodedText.Encode("normalizer"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropSplitQueriesOnWhitespace = System.Text.Json.JsonEncodedText.Encode("split_queries_on_whitespace"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override KeywordProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEagerGlobalOrdinals = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexOptions = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNormalizer = default; + LocalJsonProperty propNorms = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propSimilarity = default; + LocalJsonProperty propSplitQueriesOnWhitespace = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNormalizer.TryRead(ref reader, options, PropNormalizer)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propSplitQueriesOnWhitespace.TryRead(ref reader, options, PropSplitQueriesOnWhitespace)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KeywordProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + Meta = propMeta.Value +, + Normalizer = propNormalizer.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Similarity = propSimilarity.Value +, + SplitQueriesOnWhitespace = propSplitQueriesOnWhitespace.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeywordProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNormalizer, value.Normalizer); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropSplitQueriesOnWhitespace, value.SplitQueriesOnWhitespace); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KeywordPropertyConverter))] public sealed partial class KeywordProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.IndexOptions? IndexOptions { get; set; } /// @@ -54,28 +267,17 @@ public sealed partial class KeywordProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("normalizer")] public string? Normalizer { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("split_queries_on_whitespace")] public bool? SplitQueriesOnWhitespace { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "keyword"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongNumberProperty.g.cs index b96b7870eef..f86f018942f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class LongNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LongNumberPropertyConverter))] public sealed partial class LongNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class LongNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public long? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "long"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongRangeProperty.g.cs index 8237b58c9eb..7568f02d360 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/LongRangeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class LongRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LongRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LongRangePropertyConverter))] public sealed partial class LongRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +186,10 @@ public sealed partial class LongRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "long_range"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs index 25409117667..a6df7cdd596 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,67 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class MatchOnlyTextPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override MatchOnlyTextProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propFields = default; + LocalJsonProperty?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchOnlyTextProperty + { + CopyTo = propCopyTo.Value +, + Fields = propFields.Value +, + Meta = propMeta.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchOnlyTextProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// A variant of text that trades scoring and efficiency of positional queries for space efficiency. This field @@ -36,6 +98,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; /// to verify whether a phrase matches. All queries return constant scores that are equal to 1.0. /// /// +[JsonConverter(typeof(MatchOnlyTextPropertyConverter))] public sealed partial class MatchOnlyTextProperty : IProperty { /// @@ -44,8 +107,6 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// field, which can then be queried as a single field. /// /// - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } /// @@ -54,7 +115,6 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers. /// /// - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } /// @@ -62,10 +122,8 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "match_only_text"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Murmur3HashProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Murmur3HashProperty.g.cs index 5c7491fbe11..a18ff495302 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Murmur3HashProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Murmur3HashProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,124 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class Murmur3HashPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override Murmur3HashProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Murmur3HashProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Murmur3HashProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(Murmur3HashPropertyConverter))] public sealed partial class Murmur3HashProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +153,10 @@ public sealed partial class Murmur3HashProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "murmur3"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/NestedProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/NestedProperty.g.cs index e632c686608..ffdd1388723 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/NestedProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/NestedProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,146 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class NestedPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeInParent = System.Text.Json.JsonEncodedText.Encode("include_in_parent"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeInRoot = System.Text.Json.JsonEncodedText.Encode("include_in_root"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NestedProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIncludeInParent = default; + LocalJsonProperty propIncludeInRoot = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIncludeInParent.TryRead(ref reader, options, PropIncludeInParent)) + { + continue; + } + + if (propIncludeInRoot.TryRead(ref reader, options, PropIncludeInRoot)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NestedProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IncludeInParent = propIncludeInParent.Value +, + IncludeInRoot = propIncludeInRoot.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NestedProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIncludeInParent, value.IncludeInParent); + writer.WriteProperty(options, PropIncludeInRoot, value.IncludeInRoot); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NestedPropertyConverter))] public sealed partial class NestedProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("include_in_parent")] public bool? IncludeInParent { get; set; } - [JsonInclude, JsonPropertyName("include_in_root")] public bool? IncludeInRoot { get; set; } /// @@ -50,14 +175,10 @@ public sealed partial class NestedProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "nested"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ObjectProperty.g.cs index 39d02cbef85..149d8e67294 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ObjectProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,134 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class ObjectPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropSubobjects = System.Text.Json.JsonEncodedText.Encode("subobjects"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ObjectProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propSubobjects = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propSubobjects.TryRead(ref reader, options, PropSubobjects)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ObjectProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + Subobjects = propSubobjects.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ObjectProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropSubobjects, value.Subobjects); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ObjectPropertyConverter))] public sealed partial class ObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +163,11 @@ public sealed partial class ObjectProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("subobjects")] public bool? Subobjects { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "object"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs index d7451d3544d..ee76a236221 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,144 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class PassthroughObjectPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PassthroughObjectProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEnabled = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PassthroughObjectProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Priority = propPriority.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PassthroughObjectProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PassthroughObjectPropertyConverter))] public sealed partial class PassthroughObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,18 +173,12 @@ public sealed partial class PassthroughObjectProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "passthrough"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PointProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PointProperty.g.cs index 5dae9fbd8da..d43f8c4fdb7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/PointProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,22 +28,156 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class PointPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PointProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIgnoreZValue = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PointProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PointProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PointPropertyConverter))] public sealed partial class PointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -50,16 +185,11 @@ public sealed partial class PointProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "point"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Properties.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Properties.g.cs index 1b9d4985eae..a23b5a1eaa5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Properties.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/Properties.g.cs @@ -19,6 +19,7 @@ using Elastic.Clients.Elasticsearch.Serverless.Core; using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using Elastic.Transport; using System; @@ -318,289 +319,238 @@ public PropertiesDescriptor() : base(new Properties()) public PropertiesDescriptor Wildcard(Expression> propertyName, Action> configure) => AssignVariant, WildcardProperty>(propertyName, configure); } -internal sealed partial class PropertyInterfaceConverter : JsonConverter +internal sealed partial class PropertyInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override IProperty Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "object"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "aggregate_metric_double": - return JsonSerializer.Deserialize(ref reader, options); - case "binary": - return JsonSerializer.Deserialize(ref reader, options); - case "boolean": - return JsonSerializer.Deserialize(ref reader, options); - case "byte": - return JsonSerializer.Deserialize(ref reader, options); - case "completion": - return JsonSerializer.Deserialize(ref reader, options); - case "constant_keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "date_nanos": - return JsonSerializer.Deserialize(ref reader, options); - case "date": - return JsonSerializer.Deserialize(ref reader, options); - case "date_range": - return JsonSerializer.Deserialize(ref reader, options); - case "dense_vector": - return JsonSerializer.Deserialize(ref reader, options); - case "double": - return JsonSerializer.Deserialize(ref reader, options); - case "double_range": - return JsonSerializer.Deserialize(ref reader, options); - case "{dynamic_type}": - return JsonSerializer.Deserialize(ref reader, options); - case "alias": - return JsonSerializer.Deserialize(ref reader, options); - case "flattened": - return JsonSerializer.Deserialize(ref reader, options); - case "float": - return JsonSerializer.Deserialize(ref reader, options); - case "float_range": - return JsonSerializer.Deserialize(ref reader, options); - case "geo_point": - return JsonSerializer.Deserialize(ref reader, options); - case "geo_shape": - return JsonSerializer.Deserialize(ref reader, options); - case "half_float": - return JsonSerializer.Deserialize(ref reader, options); - case "histogram": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_collation_keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "integer": - return JsonSerializer.Deserialize(ref reader, options); - case "integer_range": - return JsonSerializer.Deserialize(ref reader, options); - case "ip": - return JsonSerializer.Deserialize(ref reader, options); - case "ip_range": - return JsonSerializer.Deserialize(ref reader, options); - case "join": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "long": - return JsonSerializer.Deserialize(ref reader, options); - case "long_range": - return JsonSerializer.Deserialize(ref reader, options); - case "match_only_text": - return JsonSerializer.Deserialize(ref reader, options); - case "murmur3": - return JsonSerializer.Deserialize(ref reader, options); - case "nested": - return JsonSerializer.Deserialize(ref reader, options); - case "object": - return JsonSerializer.Deserialize(ref reader, options); - case "passthrough": - return JsonSerializer.Deserialize(ref reader, options); - case "percolator": - return JsonSerializer.Deserialize(ref reader, options); - case "point": - return JsonSerializer.Deserialize(ref reader, options); - case "rank_feature": - return JsonSerializer.Deserialize(ref reader, options); - case "rank_features": - return JsonSerializer.Deserialize(ref reader, options); - case "scaled_float": - return JsonSerializer.Deserialize(ref reader, options); - case "search_as_you_type": - return JsonSerializer.Deserialize(ref reader, options); - case "semantic_text": - return JsonSerializer.Deserialize(ref reader, options); - case "shape": - return JsonSerializer.Deserialize(ref reader, options); - case "short": - return JsonSerializer.Deserialize(ref reader, options); - case "sparse_vector": - return JsonSerializer.Deserialize(ref reader, options); - case "text": - return JsonSerializer.Deserialize(ref reader, options); - case "token_count": - return JsonSerializer.Deserialize(ref reader, options); - case "unsigned_long": - return JsonSerializer.Deserialize(ref reader, options); - case "version": - return JsonSerializer.Deserialize(ref reader, options); - case "wildcard": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "aggregate_metric_double" => reader.ReadValue(options), + "binary" => reader.ReadValue(options), + "boolean" => reader.ReadValue(options), + "byte" => reader.ReadValue(options), + "completion" => reader.ReadValue(options), + "constant_keyword" => reader.ReadValue(options), + "date_nanos" => reader.ReadValue(options), + "date" => reader.ReadValue(options), + "date_range" => reader.ReadValue(options), + "dense_vector" => reader.ReadValue(options), + "double" => reader.ReadValue(options), + "double_range" => reader.ReadValue(options), + "{dynamic_type}" => reader.ReadValue(options), + "alias" => reader.ReadValue(options), + "flattened" => reader.ReadValue(options), + "float" => reader.ReadValue(options), + "float_range" => reader.ReadValue(options), + "geo_point" => reader.ReadValue(options), + "geo_shape" => reader.ReadValue(options), + "half_float" => reader.ReadValue(options), + "histogram" => reader.ReadValue(options), + "icu_collation_keyword" => reader.ReadValue(options), + "integer" => reader.ReadValue(options), + "integer_range" => reader.ReadValue(options), + "ip" => reader.ReadValue(options), + "ip_range" => reader.ReadValue(options), + "join" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "long" => reader.ReadValue(options), + "long_range" => reader.ReadValue(options), + "match_only_text" => reader.ReadValue(options), + "murmur3" => reader.ReadValue(options), + "nested" => reader.ReadValue(options), + "object" => reader.ReadValue(options), + "passthrough" => reader.ReadValue(options), + "percolator" => reader.ReadValue(options), + "point" => reader.ReadValue(options), + "rank_feature" => reader.ReadValue(options), + "rank_features" => reader.ReadValue(options), + "scaled_float" => reader.ReadValue(options), + "search_as_you_type" => reader.ReadValue(options), + "semantic_text" => reader.ReadValue(options), + "shape" => reader.ReadValue(options), + "short" => reader.ReadValue(options), + "sparse_vector" => reader.ReadValue(options), + "text" => reader.ReadValue(options), + "token_count" => reader.ReadValue(options), + "unsigned_long" => reader.ReadValue(options), + "version" => reader.ReadValue(options), + "wildcard" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IProperty)}'.") + }; } - public override void Write(Utf8JsonWriter writer, IProperty value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IProperty value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "aggregate_metric_double": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.AggregateMetricDoubleProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.AggregateMetricDoubleProperty)value); + break; case "binary": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.BinaryProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.BinaryProperty)value); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.BooleanProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.BooleanProperty)value); + break; case "byte": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ByteNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ByteNumberProperty)value); + break; case "completion": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.CompletionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.CompletionProperty)value); + break; case "constant_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ConstantKeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ConstantKeywordProperty)value); + break; case "date_nanos": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DateNanosProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DateNanosProperty)value); + break; case "date": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DateProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DateProperty)value); + break; case "date_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DateRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DateRangeProperty)value); + break; case "dense_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DenseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DenseVectorProperty)value); + break; case "double": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DoubleNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DoubleNumberProperty)value); + break; case "double_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DoubleRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DoubleRangeProperty)value); + break; case "{dynamic_type}": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicProperty)value); + break; case "alias": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.FieldAliasProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.FieldAliasProperty)value); + break; case "flattened": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.FlattenedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.FlattenedProperty)value); + break; case "float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.FloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.FloatNumberProperty)value); + break; case "float_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.FloatRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.FloatRangeProperty)value); + break; case "geo_point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoPointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoPointProperty)value); + break; case "geo_shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoShapeProperty)value); + break; case "half_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.HalfFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.HalfFloatNumberProperty)value); + break; case "histogram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.HistogramProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.HistogramProperty)value); + break; case "icu_collation_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.IcuCollationProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IcuCollationProperty)value); + break; case "integer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.IntegerNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IntegerNumberProperty)value); + break; case "integer_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.IntegerRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IntegerRangeProperty)value); + break; case "ip": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.IpProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IpProperty)value); + break; case "ip_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.IpRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.IpRangeProperty)value); + break; case "join": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.JoinProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.JoinProperty)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.KeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.KeywordProperty)value); + break; case "long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.LongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.LongNumberProperty)value); + break; case "long_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.LongRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.LongRangeProperty)value); + break; case "match_only_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.MatchOnlyTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.MatchOnlyTextProperty)value); + break; case "murmur3": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.Murmur3HashProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.Murmur3HashProperty)value); + break; case "nested": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.NestedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.NestedProperty)value); + break; case "object": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ObjectProperty)value); + break; case "passthrough": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.PassthroughObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.PassthroughObjectProperty)value); + break; case "percolator": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.PercolatorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.PercolatorProperty)value); + break; case "point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.PointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.PointProperty)value); + break; case "rank_feature": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.RankFeatureProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.RankFeatureProperty)value); + break; case "rank_features": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.RankFeaturesProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.RankFeaturesProperty)value); + break; case "scaled_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ScaledFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ScaledFloatNumberProperty)value); + break; case "search_as_you_type": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.SearchAsYouTypeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.SearchAsYouTypeProperty)value); + break; case "semantic_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.SemanticTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.SemanticTextProperty)value); + break; case "shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ShapeProperty)value); + break; case "short": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.ShortNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.ShortNumberProperty)value); + break; case "sparse_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.SparseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.SparseVectorProperty)value); + break; case "text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.TextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.TextProperty)value); + break; case "token_count": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.TokenCountProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.TokenCountProperty)value); + break; case "unsigned_long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.UnsignedLongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.UnsignedLongNumberProperty)value); + break; case "version": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.VersionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.VersionProperty)value); + break; case "wildcard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Serverless.Mapping.WildcardProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Serverless.Mapping.WildcardProperty)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IProperty)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs index 8529c1ecd63..b0e76338cca 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,11 +28,63 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class RuntimeFieldFetchFieldsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + + public override RuntimeFieldFetchFields Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propFormat = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new RuntimeFieldFetchFields { Field = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RuntimeFieldFetchFields + { + Field = propField.Value +, + Format = propFormat.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuntimeFieldFetchFields value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuntimeFieldFetchFieldsConverter))] public sealed partial class RuntimeFieldFetchFields { - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs index 2f3f8288c6f..8555744e4e6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,208 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class ScaledFloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScalingFactor = System.Text.Json.JsonEncodedText.Encode("scaling_factor"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ScaledFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScalingFactor = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScalingFactor.TryRead(ref reader, options, PropScalingFactor)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScaledFloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + ScalingFactor = propScalingFactor.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScaledFloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScalingFactor, value.ScalingFactor); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ScaledFloatNumberPropertyConverter))] public sealed partial class ScaledFloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,22 +237,14 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("scaling_factor")] public double? ScalingFactor { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "scaled_float"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs index ac3109d0e5a..b8c0ead3d82 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,24 +28,207 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class SearchAsYouTypePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropMaxShingleSize = System.Text.Json.JsonEncodedText.Encode("max_shingle_size"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SearchAsYouTypeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexOptions = default; + LocalJsonProperty propMaxShingleSize = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNorms = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propSearchAnalyzer = default; + LocalJsonProperty propSearchQuoteAnalyzer = default; + LocalJsonProperty propSimilarity = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propMaxShingleSize.TryRead(ref reader, options, PropMaxShingleSize)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchAsYouTypeProperty + { + Analyzer = propAnalyzer.Value +, + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + MaxShingleSize = propMaxShingleSize.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Similarity = propSimilarity.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchAsYouTypeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropMaxShingleSize, value.MaxShingleSize); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchAsYouTypePropertyConverter))] public sealed partial class SearchAsYouTypeProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("max_shingle_size")] public int? MaxShingleSize { get; set; } /// @@ -52,24 +236,15 @@ public sealed partial class SearchAsYouTypeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "search_as_you_type"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShapeProperty.g.cs index 18ab1659da1..6d53146802f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShapeProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,157 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class ShapePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropOrientation = System.Text.Json.JsonEncodedText.Encode("orientation"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ShapeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIgnoreZValue = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propOrientation = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propOrientation.TryRead(ref reader, options, PropOrientation)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShapeProperty + { + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + Orientation = propOrientation.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropOrientation, value.Orientation); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// The shape data type facilitates the indexing of and searching with arbitrary x, y cartesian shapes such as @@ -34,24 +186,16 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(ShapePropertyConverter))] public sealed partial class ShapeProperty : IProperty { - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -59,16 +203,11 @@ public sealed partial class ShapeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("orientation")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "shape"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShortNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShortNumberProperty.g.cs index d83c6802a26..9fc8b81e154 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShortNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/ShortNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class ShortNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ShortNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShortNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShortNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShortNumberPropertyConverter))] public sealed partial class ShortNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class ShortNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public short? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "short"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TextProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TextProperty.g.cs index 75c78c9a1b9..82cd2259a91 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TextProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,34 +28,272 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class TextPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFielddataFrequencyFilter = System.Text.Json.JsonEncodedText.Encode("fielddata_frequency_filter"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPhrases = System.Text.Json.JsonEncodedText.Encode("index_phrases"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPrefixes = System.Text.Json.JsonEncodedText.Encode("index_prefixes"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TextProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEagerGlobalOrdinals = default; + LocalJsonProperty propFielddata = default; + LocalJsonProperty propFielddataFrequencyFilter = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty propIndexOptions = default; + LocalJsonProperty propIndexPhrases = default; + LocalJsonProperty propIndexPrefixes = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNorms = default; + LocalJsonProperty propPositionIncrementGap = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propSearchAnalyzer = default; + LocalJsonProperty propSearchQuoteAnalyzer = default; + LocalJsonProperty propSimilarity = default; + LocalJsonProperty propStore = default; + LocalJsonProperty propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFielddataFrequencyFilter.TryRead(ref reader, options, PropFielddataFrequencyFilter)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propIndexPhrases.TryRead(ref reader, options, PropIndexPhrases)) + { + continue; + } + + if (propIndexPrefixes.TryRead(ref reader, options, PropIndexPrefixes)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TextProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Fielddata = propFielddata.Value +, + FielddataFrequencyFilter = propFielddataFrequencyFilter.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + IndexPhrases = propIndexPhrases.Value +, + IndexPrefixes = propIndexPrefixes.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Similarity = propSimilarity.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TextProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFielddataFrequencyFilter, value.FielddataFrequencyFilter); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TextPropertyConverter))] public sealed partial class TextProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public bool? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fielddata_frequency_filter")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.FielddataFrequencyFilter? FielddataFrequencyFilter { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } /// @@ -62,26 +301,16 @@ public sealed partial class TextProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "text"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TokenCountProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TokenCountProperty.g.cs index 8f5f9b0aaa7..e722477e23f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TokenCountProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/TokenCountProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,178 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class TokenCountPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnablePositionIncrements = System.Text.Json.JsonEncodedText.Encode("enable_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TokenCountProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propEnablePositionIncrements = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnablePositionIncrements.TryRead(ref reader, options, PropEnablePositionIncrements)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TokenCountProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EnablePositionIncrements = propEnablePositionIncrements.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenCountProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnablePositionIncrements, value.EnablePositionIncrements); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TokenCountPropertyConverter))] public sealed partial class TokenCountProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enable_position_increments")] public bool? EnablePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,16 +207,11 @@ public sealed partial class TokenCountProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "token_count"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs index fbf3e48aad7..3a8c5bb5ad1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,26 +28,198 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class UnsignedLongNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override UnsignedLongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCoerce = default; + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty propIgnoreMalformed = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propOnScriptError = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propScript = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnsignedLongNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnsignedLongNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UnsignedLongNumberPropertyConverter))] public sealed partial class UnsignedLongNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,20 +227,13 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public long? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "unsigned_long"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/VersionProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/VersionProperty.g.cs index 44e9c097d81..2796541704b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/VersionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/VersionProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,124 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class VersionPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override VersionProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VersionProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, VersionProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VersionPropertyConverter))] public sealed partial class VersionProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +153,10 @@ public sealed partial class VersionProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "version"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/WildcardProperty.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/WildcardProperty.g.cs index 3361d4ac704..0b23b7bf081 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/WildcardProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Mapping/WildcardProperty.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,18 +28,134 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Mapping; +internal sealed partial class WildcardPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override WildcardProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propCopyTo = default; + LocalJsonProperty propDocValues = default; + LocalJsonProperty propDynamic = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propIgnoreAbove = default; + LocalJsonProperty?> propMeta = default; + LocalJsonProperty propNullValue = default; + LocalJsonProperty propProperties = default; + LocalJsonProperty propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new WildcardProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, WildcardProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(WildcardPropertyConverter))] public sealed partial class WildcardProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +163,11 @@ public sealed partial class WildcardProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Serverless.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "wildcard"; } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoDiscover.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoDiscover.g.cs index ab16ddd86ef..28d73f18045 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoDiscover.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoDiscover.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,51 +28,70 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; -internal sealed partial class NodeInfoDiscoverConverter : JsonConverter +internal sealed partial class NodeInfoDiscoverConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeInfoDiscover Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSeedHosts = System.Text.Json.JsonEncodedText.Encode("seed_hosts"); + private static readonly System.Text.Json.JsonEncodedText PropSeedProviders = System.Text.Json.JsonEncodedText.Encode("seed_providers"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NodeInfoDiscover Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection? seedHosts = default; - IReadOnlyCollection? seedProviders = default; - string? type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propSettings = default; + LocalJsonProperty?> propSeedHosts = default; + LocalJsonProperty?> propSeedProviders = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propSeedHosts.TryRead(ref reader, options, PropSeedHosts)) { - var property = reader.GetString(); - if (property == "seed_hosts") - { - seedHosts = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seed_providers") - { - seedProviders = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; + } - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propSeedProviders.TryRead(ref reader, options, PropSeedProviders)) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propType.TryRead(ref reader, options, PropType)) + { + continue; } + + propSettings ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propSettings[key] = value; } - return new NodeInfoDiscover { SeedHosts = seedHosts, SeedProviders = seedProviders, Settings = additionalProperties, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoDiscover + { + Settings = propSettings +, + SeedHosts = propSeedHosts.Value +, + SeedProviders = propSeedProviders.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, NodeInfoDiscover value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoDiscover value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NodeInfoDiscover' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropSeedHosts, value.SeedHosts); + writer.WriteProperty(options, PropSeedProviders, value.SeedProviders); + writer.WriteProperty(options, PropType, value.Type); + if (value.Settings is not null) + { + foreach (var item in value.Settings) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoPath.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoPath.g.cs index c176bb5a08f..f8181852e95 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoPath.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoPath.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,15 +28,74 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodeInfoPathConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropHome = System.Text.Json.JsonEncodedText.Encode("home"); + private static readonly System.Text.Json.JsonEncodedText PropLogs = System.Text.Json.JsonEncodedText.Encode("logs"); + private static readonly System.Text.Json.JsonEncodedText PropRepo = System.Text.Json.JsonEncodedText.Encode("repo"); + + public override NodeInfoPath Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propData = default; + LocalJsonProperty propHome = default; + LocalJsonProperty propLogs = default; + LocalJsonProperty?> propRepo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propHome.TryRead(ref reader, options, PropHome)) + { + continue; + } + + if (propLogs.TryRead(ref reader, options, PropLogs)) + { + continue; + } + + if (propRepo.TryRead(ref reader, options, PropRepo)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoPath + { + Data = propData.Value +, + Home = propHome.Value +, + Logs = propLogs.Value +, + Repo = propRepo.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoPath value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropHome, value.Home); + writer.WriteProperty(options, PropLogs, value.Logs); + writer.WriteProperty(options, PropRepo, value.Repo); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoPathConverter))] public sealed partial class NodeInfoPath { - [JsonInclude, JsonPropertyName("data")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Data { get; init; } - [JsonInclude, JsonPropertyName("home")] public string? Home { get; init; } - [JsonInclude, JsonPropertyName("logs")] public string? Logs { get; init; } - [JsonInclude, JsonPropertyName("repo")] public IReadOnlyCollection? Repo { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs index ea8d393b8c3..5ed7248bf83 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,8 +28,47 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodeInfoSettingsHttpTypeConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override NodeInfoSettingsHttpType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new NodeInfoSettingsHttpType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryRead(ref reader, options, PropDefault)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsHttpType + { + Default = propDefault.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsHttpType value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefault, value.Default); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsHttpTypeConverter))] public sealed partial class NodeInfoSettingsHttpType { - [JsonInclude, JsonPropertyName("default")] public string Default { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs index f845950e3bb..16ae2415e9b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,9 +28,41 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodeInfoSettingsNetworkConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHost = System.Text.Json.JsonEncodedText.Encode("host"); + + public override NodeInfoSettingsNetwork Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propHost = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHost.TryRead(ref reader, options, PropHost, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsNetwork + { + Host = propHost.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsNetwork value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHost, value.Host, typeof(SingleOrManyMarker?, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsNetworkConverter))] public sealed partial class NodeInfoSettingsNetwork { - [JsonInclude, JsonPropertyName("host")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Host { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs index f08f1144e14..c75176d4bcc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,8 +28,47 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class NodeInfoSettingsTransportTypeConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override NodeInfoSettingsTransportType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new NodeInfoSettingsTransportType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryRead(ref reader, options, PropDefault)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsTransportType + { + Default = propDefault.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsTransportType value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefault, value.Default); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsTransportTypeConverter))] public sealed partial class NodeInfoSettingsTransportType { - [JsonInclude, JsonPropertyName("default")] public string Default { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeJvmInfo.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeJvmInfo.g.cs index 9c93c25fd84..a73f23a7fe6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeJvmInfo.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/NodeJvmInfo.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,109 +28,147 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; -internal sealed partial class NodeJvmInfoConverter : JsonConverter +internal sealed partial class NodeJvmInfoConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeJvmInfo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropGcCollectors = System.Text.Json.JsonEncodedText.Encode("gc_collectors"); + private static readonly System.Text.Json.JsonEncodedText PropInputArguments = System.Text.Json.JsonEncodedText.Encode("input_arguments"); + private static readonly System.Text.Json.JsonEncodedText PropMem = System.Text.Json.JsonEncodedText.Encode("mem"); + private static readonly System.Text.Json.JsonEncodedText PropMemoryPools = System.Text.Json.JsonEncodedText.Encode("memory_pools"); + private static readonly System.Text.Json.JsonEncodedText PropPid = System.Text.Json.JsonEncodedText.Encode("pid"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropUsingBundledJdk = System.Text.Json.JsonEncodedText.Encode("using_bundled_jdk"); + private static readonly System.Text.Json.JsonEncodedText PropUsingBundledJdk1 = System.Text.Json.JsonEncodedText.Encode("bundled_jdk"); + private static readonly System.Text.Json.JsonEncodedText PropUsingCompressedOrdinaryObjectPointers = System.Text.Json.JsonEncodedText.Encode("using_compressed_ordinary_object_pointers"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVmName = System.Text.Json.JsonEncodedText.Encode("vm_name"); + private static readonly System.Text.Json.JsonEncodedText PropVmVendor = System.Text.Json.JsonEncodedText.Encode("vm_vendor"); + private static readonly System.Text.Json.JsonEncodedText PropVmVersion = System.Text.Json.JsonEncodedText.Encode("vm_version"); + + public override NodeJvmInfo Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection gcCollectors = default; - IReadOnlyCollection inputArguments = default; - Elastic.Clients.Elasticsearch.Serverless.Nodes.NodeInfoJvmMemory mem = default; - IReadOnlyCollection memoryPools = default; - int pid = default; - long startTimeInMillis = default; - bool usingBundledJdk = default; - object? usingCompressedOrdinaryObjectPointers = default; - string version = default; - string vmName = default; - string vmVendor = default; - string vmVersion = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty> propGcCollectors = default; + LocalJsonProperty> propInputArguments = default; + LocalJsonProperty propMem = default; + LocalJsonProperty> propMemoryPools = default; + LocalJsonProperty propPid = default; + LocalJsonProperty propStartTimeInMillis = default; + LocalJsonProperty propUsingBundledJdk = default; + LocalJsonProperty propUsingCompressedOrdinaryObjectPointers = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVmName = default; + LocalJsonProperty propVmVendor = default; + LocalJsonProperty propVmVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propGcCollectors.TryRead(ref reader, options, PropGcCollectors)) { - var property = reader.GetString(); - if (property == "gc_collectors") - { - gcCollectors = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "input_arguments") - { - inputArguments = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "mem") - { - mem = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "memory_pools") - { - memoryPools = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "pid") - { - pid = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "start_time_in_millis") - { - startTimeInMillis = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "using_bundled_jdk" || property == "bundled_jdk") - { - usingBundledJdk = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "using_compressed_ordinary_object_pointers") - { - usingCompressedOrdinaryObjectPointers = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_name") - { - vmName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_vendor") - { - vmVendor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_version") - { - vmVersion = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } + + if (propInputArguments.TryRead(ref reader, options, PropInputArguments)) + { + continue; + } + + if (propMem.TryRead(ref reader, options, PropMem)) + { + continue; + } + + if (propMemoryPools.TryRead(ref reader, options, PropMemoryPools)) + { + continue; + } + + if (propPid.TryRead(ref reader, options, PropPid)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + if (propUsingBundledJdk.TryRead(ref reader, options, PropUsingBundledJdk) || propUsingBundledJdk.TryRead(ref reader, options, PropUsingBundledJdk1)) + { + continue; + } + + if (propUsingCompressedOrdinaryObjectPointers.TryRead(ref reader, options, PropUsingCompressedOrdinaryObjectPointers)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVmName.TryRead(ref reader, options, PropVmName)) + { + continue; + } + + if (propVmVendor.TryRead(ref reader, options, PropVmVendor)) + { + continue; + } + + if (propVmVersion.TryRead(ref reader, options, PropVmVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - return new NodeJvmInfo { GcCollectors = gcCollectors, InputArguments = inputArguments, Mem = mem, MemoryPools = memoryPools, Pid = pid, StartTimeInMillis = startTimeInMillis, UsingBundledJdk = usingBundledJdk, UsingCompressedOrdinaryObjectPointers = usingCompressedOrdinaryObjectPointers, Version = version, VmName = vmName, VmVendor = vmVendor, VmVersion = vmVersion }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeJvmInfo + { + GcCollectors = propGcCollectors.Value +, + InputArguments = propInputArguments.Value +, + Mem = propMem.Value +, + MemoryPools = propMemoryPools.Value +, + Pid = propPid.Value +, + StartTimeInMillis = propStartTimeInMillis.Value +, + UsingBundledJdk = propUsingBundledJdk.Value +, + UsingCompressedOrdinaryObjectPointers = propUsingCompressedOrdinaryObjectPointers.Value +, + Version = propVersion.Value +, + VmName = propVmName.Value +, + VmVendor = propVmVendor.Value +, + VmVersion = propVmVersion.Value + }; } - public override void Write(Utf8JsonWriter writer, NodeJvmInfo value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeJvmInfo value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NodeJvmInfo' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropGcCollectors, value.GcCollectors); + writer.WriteProperty(options, PropInputArguments, value.InputArguments); + writer.WriteProperty(options, PropMem, value.Mem); + writer.WriteProperty(options, PropMemoryPools, value.MemoryPools); + writer.WriteProperty(options, PropPid, value.Pid); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteProperty(options, PropUsingBundledJdk, value.UsingBundledJdk); + writer.WriteProperty(options, PropUsingCompressedOrdinaryObjectPointers, value.UsingCompressedOrdinaryObjectPointers); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVmName, value.VmName); + writer.WriteProperty(options, PropVmVendor, value.VmVendor); + writer.WriteProperty(options, PropVmVersion, value.VmVersion); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/Stats.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/Stats.g.cs index 5fa4360b7c1..0ceaeb9d59f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/Stats.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Nodes/Stats.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,250 @@ namespace Elastic.Clients.Elasticsearch.Serverless.Nodes; +internal sealed partial class StatsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAdaptiveSelection = System.Text.Json.JsonEncodedText.Encode("adaptive_selection"); + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropBreakers = System.Text.Json.JsonEncodedText.Encode("breakers"); + private static readonly System.Text.Json.JsonEncodedText PropDiscovery = System.Text.Json.JsonEncodedText.Encode("discovery"); + private static readonly System.Text.Json.JsonEncodedText PropFs = System.Text.Json.JsonEncodedText.Encode("fs"); + private static readonly System.Text.Json.JsonEncodedText PropHost = System.Text.Json.JsonEncodedText.Encode("host"); + private static readonly System.Text.Json.JsonEncodedText PropHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingPressure = System.Text.Json.JsonEncodedText.Encode("indexing_pressure"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText PropIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText PropJvm = System.Text.Json.JsonEncodedText.Encode("jvm"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropOs = System.Text.Json.JsonEncodedText.Encode("os"); + private static readonly System.Text.Json.JsonEncodedText PropProcess = System.Text.Json.JsonEncodedText.Encode("process"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptCache = System.Text.Json.JsonEncodedText.Encode("script_cache"); + private static readonly System.Text.Json.JsonEncodedText PropThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + private static readonly System.Text.Json.JsonEncodedText PropTimestamp = System.Text.Json.JsonEncodedText.Encode("timestamp"); + private static readonly System.Text.Json.JsonEncodedText PropTransport = System.Text.Json.JsonEncodedText.Encode("transport"); + private static readonly System.Text.Json.JsonEncodedText PropTransportAddress = System.Text.Json.JsonEncodedText.Encode("transport_address"); + + public override Stats Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propAdaptiveSelection = default; + LocalJsonProperty?> propAttributes = default; + LocalJsonProperty?> propBreakers = default; + LocalJsonProperty propDiscovery = default; + LocalJsonProperty propFs = default; + LocalJsonProperty propHost = default; + LocalJsonProperty propHttp = default; + LocalJsonProperty propIndexingPressure = default; + LocalJsonProperty propIndices = default; + LocalJsonProperty propIngest = default; + LocalJsonProperty?> propIp = default; + LocalJsonProperty propJvm = default; + LocalJsonProperty propName = default; + LocalJsonProperty propOs = default; + LocalJsonProperty propProcess = default; + LocalJsonProperty?> propRoles = default; + LocalJsonProperty propScript = default; + LocalJsonProperty>>?> propScriptCache = default; + LocalJsonProperty?> propThreadPool = default; + LocalJsonProperty propTimestamp = default; + LocalJsonProperty propTransport = default; + LocalJsonProperty propTransportAddress = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAdaptiveSelection.TryRead(ref reader, options, PropAdaptiveSelection)) + { + continue; + } + + if (propAttributes.TryRead(ref reader, options, PropAttributes)) + { + continue; + } + + if (propBreakers.TryRead(ref reader, options, PropBreakers)) + { + continue; + } + + if (propDiscovery.TryRead(ref reader, options, PropDiscovery)) + { + continue; + } + + if (propFs.TryRead(ref reader, options, PropFs)) + { + continue; + } + + if (propHost.TryRead(ref reader, options, PropHost)) + { + continue; + } + + if (propHttp.TryRead(ref reader, options, PropHttp)) + { + continue; + } + + if (propIndexingPressure.TryRead(ref reader, options, PropIndexingPressure)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propIp.TryRead(ref reader, options, PropIp, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propJvm.TryRead(ref reader, options, PropJvm)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propOs.TryRead(ref reader, options, PropOs)) + { + continue; + } + + if (propProcess.TryRead(ref reader, options, PropProcess)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptCache.TryRead(ref reader, options, PropScriptCache)) + { + continue; + } + + if (propThreadPool.TryRead(ref reader, options, PropThreadPool)) + { + continue; + } + + if (propTimestamp.TryRead(ref reader, options, PropTimestamp)) + { + continue; + } + + if (propTransport.TryRead(ref reader, options, PropTransport)) + { + continue; + } + + if (propTransportAddress.TryRead(ref reader, options, PropTransportAddress)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Stats + { + AdaptiveSelection = propAdaptiveSelection.Value +, + Attributes = propAttributes.Value +, + Breakers = propBreakers.Value +, + Discovery = propDiscovery.Value +, + Fs = propFs.Value +, + Host = propHost.Value +, + Http = propHttp.Value +, + IndexingPressure = propIndexingPressure.Value +, + Indices = propIndices.Value +, + Ingest = propIngest.Value +, + Ip = propIp.Value +, + Jvm = propJvm.Value +, + Name = propName.Value +, + Os = propOs.Value +, + Process = propProcess.Value +, + Roles = propRoles.Value +, + Script = propScript.Value +, + ScriptCache = propScriptCache.Value +, + ThreadPool = propThreadPool.Value +, + Timestamp = propTimestamp.Value +, + Transport = propTransport.Value +, + TransportAddress = propTransportAddress.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Stats value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAdaptiveSelection, value.AdaptiveSelection); + writer.WriteProperty(options, PropAttributes, value.Attributes); + writer.WriteProperty(options, PropBreakers, value.Breakers); + writer.WriteProperty(options, PropDiscovery, value.Discovery); + writer.WriteProperty(options, PropFs, value.Fs); + writer.WriteProperty(options, PropHost, value.Host); + writer.WriteProperty(options, PropHttp, value.Http); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropIp, value.Ip, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropJvm, value.Jvm); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropOs, value.Os); + writer.WriteProperty(options, PropProcess, value.Process); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptCache, value.ScriptCache); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool); + writer.WriteProperty(options, PropTimestamp, value.Timestamp); + writer.WriteProperty(options, PropTransport, value.Transport); + writer.WriteProperty(options, PropTransportAddress, value.TransportAddress); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StatsConverter))] public sealed partial class Stats { /// @@ -34,7 +279,6 @@ public sealed partial class Stats /// Statistics about adaptive replica selection. /// /// - [JsonInclude, JsonPropertyName("adaptive_selection")] public IReadOnlyDictionary? AdaptiveSelection { get; init; } /// @@ -42,8 +286,6 @@ public sealed partial class Stats /// Contains a list of attributes for the node. /// /// - [JsonInclude, JsonPropertyName("attributes")] - [ReadOnlyFieldDictionaryConverter(typeof(string))] public IReadOnlyDictionary? Attributes { get; init; } /// @@ -51,7 +293,6 @@ public sealed partial class Stats /// Statistics about the field data circuit breaker. /// /// - [JsonInclude, JsonPropertyName("breakers")] public IReadOnlyDictionary? Breakers { get; init; } /// @@ -59,7 +300,6 @@ public sealed partial class Stats /// Contains node discovery statistics for the node. /// /// - [JsonInclude, JsonPropertyName("discovery")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Discovery? Discovery { get; init; } /// @@ -67,7 +307,6 @@ public sealed partial class Stats /// File system information, data path, free disk space, read/write stats. /// /// - [JsonInclude, JsonPropertyName("fs")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.FileSystem? Fs { get; init; } /// @@ -75,7 +314,6 @@ public sealed partial class Stats /// Network host for the node, based on the network host setting. /// /// - [JsonInclude, JsonPropertyName("host")] public string? Host { get; init; } /// @@ -83,7 +321,6 @@ public sealed partial class Stats /// HTTP connection information. /// /// - [JsonInclude, JsonPropertyName("http")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Http? Http { get; init; } /// @@ -91,7 +328,6 @@ public sealed partial class Stats /// Contains indexing pressure statistics for the node. /// /// - [JsonInclude, JsonPropertyName("indexing_pressure")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.IndexingPressure? IndexingPressure { get; init; } /// @@ -99,7 +335,6 @@ public sealed partial class Stats /// Indices stats about size, document count, indexing and deletion times, search times, field cache size, merges and flushes. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.ShardStats? Indices { get; init; } /// @@ -107,7 +342,6 @@ public sealed partial class Stats /// Statistics about ingest preprocessing. /// /// - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Ingest? Ingest { get; init; } /// @@ -115,8 +349,6 @@ public sealed partial class Stats /// IP address and port for the node. /// /// - [JsonInclude, JsonPropertyName("ip")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Ip { get; init; } /// @@ -124,7 +356,6 @@ public sealed partial class Stats /// JVM stats, memory pool information, garbage collection, buffer pools, number of loaded/unloaded classes. /// /// - [JsonInclude, JsonPropertyName("jvm")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Jvm? Jvm { get; init; } /// @@ -133,7 +364,6 @@ public sealed partial class Stats /// Based on the node name setting. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; init; } /// @@ -141,7 +371,6 @@ public sealed partial class Stats /// Operating system stats, load average, mem, swap. /// /// - [JsonInclude, JsonPropertyName("os")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.OperatingSystem? Os { get; init; } /// @@ -149,7 +378,6 @@ public sealed partial class Stats /// Process statistics, memory consumption, cpu usage, open file descriptors. /// /// - [JsonInclude, JsonPropertyName("process")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Process? Process { get; init; } /// @@ -157,7 +385,6 @@ public sealed partial class Stats /// Roles assigned to the node. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection? Roles { get; init; } /// @@ -165,9 +392,7 @@ public sealed partial class Stats /// Contains script statistics for the node. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Scripting? Script { get; init; } - [JsonInclude, JsonPropertyName("script_cache")] public IReadOnlyDictionary>>? ScriptCache { get; init; } /// @@ -175,9 +400,7 @@ public sealed partial class Stats /// Statistics about each thread pool, including current size, queue and rejected tasks. /// /// - [JsonInclude, JsonPropertyName("thread_pool")] public IReadOnlyDictionary? ThreadPool { get; init; } - [JsonInclude, JsonPropertyName("timestamp")] public long? Timestamp { get; init; } /// @@ -185,7 +408,6 @@ public sealed partial class Stats /// Transport statistics about sent and received bytes in cluster communication. /// /// - [JsonInclude, JsonPropertyName("transport")] public Elastic.Clients.Elasticsearch.Serverless.Nodes.Transport? Transport { get; init; } /// @@ -193,6 +415,5 @@ public sealed partial class Stats /// Host and port for the transport layer, used for internal communication between nodes in a cluster. /// /// - [JsonInclude, JsonPropertyName("transport_address")] public string? TransportAddress { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/BoolQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/BoolQuery.g.cs index febf7b6dc6a..a1cb59efd4a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/BoolQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/BoolQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,100 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class BoolQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMust = System.Text.Json.JsonEncodedText.Encode("must"); + private static readonly System.Text.Json.JsonEncodedText PropMustNot = System.Text.Json.JsonEncodedText.Encode("must_not"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropShould = System.Text.Json.JsonEncodedText.Encode("should"); + + public override BoolQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty?> propMust = default; + LocalJsonProperty?> propMustNot = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty?> propShould = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propMust.TryRead(ref reader, options, PropMust, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propMustNot.TryRead(ref reader, options, PropMustNot, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propShould.TryRead(ref reader, options, PropShould, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BoolQuery + { + Boost = propBoost.Value +, + Filter = propFilter.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Must = propMust.Value +, + MustNot = propMustNot.Value +, + QueryName = propQueryName.Value +, + Should = propShould.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BoolQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMust, value.Must, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropMustNot, value.MustNot, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropShould, value.Should, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BoolQueryConverter))] public sealed partial class BoolQuery { /// @@ -37,7 +132,6 @@ public sealed partial class BoolQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -46,8 +140,6 @@ public sealed partial class BoolQuery /// However, unlike must, the score of the query will be ignored. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -55,7 +147,6 @@ public sealed partial class BoolQuery /// Specifies the number or percentage of should clauses returned documents must match. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -63,8 +154,6 @@ public sealed partial class BoolQuery /// The clause (query) must appear in matching documents and will contribute to the score. /// /// - [JsonInclude, JsonPropertyName("must")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Must { get; set; } /// @@ -73,10 +162,7 @@ public sealed partial class BoolQuery /// Because scoring is ignored, a score of 0 is returned for all documents. /// /// - [JsonInclude, JsonPropertyName("must_not")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? MustNot { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -84,8 +170,6 @@ public sealed partial class BoolQuery /// The clause (query) should appear in the matching document. /// /// - [JsonInclude, JsonPropertyName("should")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Should { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(BoolQuery boolQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.Bool(boolQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs index 5dd65d165b2..77d9907334b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class CombinedFieldsQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override CombinedFieldsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propOperator = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CombinedFieldsQuery + { + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Fields = propFields.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFields, value.Fields, typeof(FieldsMarker)); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CombinedFieldsQueryConverter))] public sealed partial class CombinedFieldsQuery { /// @@ -34,7 +139,6 @@ public sealed partial class CombinedFieldsQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -45,7 +149,6 @@ public sealed partial class CombinedFieldsQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -53,8 +156,6 @@ public sealed partial class CombinedFieldsQuery /// List of fields to search. Field wildcard patterns are allowed. Only text fields are supported, and they must all have the same search analyzer. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields Fields { get; set; } /// @@ -62,7 +163,6 @@ public sealed partial class CombinedFieldsQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -70,7 +170,6 @@ public sealed partial class CombinedFieldsQuery /// Boolean logic used to interpret text in the query value. /// /// - [JsonInclude, JsonPropertyName("operator")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.CombinedFieldsOperator? Operator { get; set; } /// @@ -79,9 +178,7 @@ public sealed partial class CombinedFieldsQuery /// The combined_fields query analyzes the provided text before performing a search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -89,7 +186,6 @@ public sealed partial class CombinedFieldsQuery /// Indicates whether no documents are returned if the analyzer removes all tokens, such as when using a stop filter. /// /// - [JsonInclude, JsonPropertyName("zero_terms_query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.CombinedFieldsZeroTerms? ZeroTermsQuery { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(CombinedFieldsQuery combinedFieldsQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.CombinedFields(combinedFieldsQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDecayFunction.g.cs index b19c4540e0f..b0a5c5fec81 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDecayFunction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,60 +28,51 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class DateDecayFunctionConverter : JsonConverter +internal sealed partial class DateDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override DateDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DateDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, DateDecayFunction value, JsonSerializerOptions options) + public override DateDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty> propPlacement = default; + LocalJsonProperty propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(DateDecayFunctionConverter))] -public sealed partial class DateDecayFunction +public sealed partial class DateDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } @@ -91,6 +83,8 @@ public sealed partial class DateDecayFunction /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "datedecayfunction"; } public sealed partial class DateDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs index 4acc19e3a1f..06d6bdf4ec1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -public sealed partial class DateDistanceFeatureQuery +public sealed partial class DateDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class DateDistanceFeatureQuery public Elastic.Clients.Elasticsearch.Serverless.Duration Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "datedistancefeaturequery"; } public sealed partial class DateDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateRangeQuery.g.cs index 685edc8185f..cd6678410d1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DateRangeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,151 +28,135 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class DateRangeQueryConverter : JsonConverter +internal sealed partial class DateRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override DateRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override DateRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new DateRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propGt = default; + LocalJsonProperty propGte = default; + LocalJsonProperty propLt = default; + LocalJsonProperty propLte = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRelation = default; + LocalJsonProperty propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_zone") - { - variant.TimeZone = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DateRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize DateRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.TimeZone)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateRangeQuery { - writer.WritePropertyName("time_zone"); - writer.WriteStringValue(value.TimeZone); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value +, + TimeZone = propTimeZone.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(DateRangeQueryConverter))] -public sealed partial class DateRangeQuery +public sealed partial class DateRangeQuery : IRangeQuery { public DateRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) { @@ -180,6 +165,10 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal DateRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +229,8 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "daterangequery"; } public sealed partial class DateRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayFunction.g.cs new file mode 100644 index 00000000000..f7fb561070a --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayFunction.g.cs @@ -0,0 +1,64 @@ +// 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. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; +using Elastic.Clients.Elasticsearch.Serverless.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; + +[JsonConverter(typeof(DecayFunctionConverter))] +public partial interface IDecayFunction +{ + public string? Type { get; } +} + +internal sealed partial class DecayFunctionConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IDecayFunction)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayPlacement.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayPlacement.g.cs index 52c7faaa5d7..d7c64e63c59 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayPlacement.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DecayPlacement.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,87 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class DecayPlacementConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDecay = System.Text.Json.JsonEncodedText.Encode("decay"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrigin = System.Text.Json.JsonEncodedText.Encode("origin"); + private static readonly System.Text.Json.JsonEncodedText PropScale = System.Text.Json.JsonEncodedText.Encode("scale"); + + public override DecayPlacement Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDecay = default; + LocalJsonProperty propOffset = default; + LocalJsonProperty propOrigin = default; + LocalJsonProperty propScale = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDecay.TryRead(ref reader, options, PropDecay)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset, typeof(SourceMarker))) + { + continue; + } + + if (propOrigin.TryRead(ref reader, options, PropOrigin, typeof(SourceMarker))) + { + continue; + } + + if (propScale.TryRead(ref reader, options, PropScale, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DecayPlacement + { + Decay = propDecay.Value +, + Offset = propOffset.Value +, + Origin = propOrigin.Value +, + Scale = propScale.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DecayPlacement value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDecay, value.Decay); + writer.WriteProperty(options, PropOffset, value.Offset, typeof(SourceMarker)); + writer.WriteProperty(options, PropOrigin, value.Origin, typeof(SourceMarker)); + writer.WriteProperty(options, PropScale, value.Scale, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class DecayPlacementConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(DecayPlacement<,>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(DecayPlacementConverter<,>).MakeGenericType(args[0], args[1]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(DecayPlacementConverterFactory))] public sealed partial class DecayPlacement { /// @@ -34,7 +116,6 @@ public sealed partial class DecayPlacement /// Defines how documents are scored at the distance given at scale. /// /// - [JsonInclude, JsonPropertyName("decay")] public double? Decay { get; set; } /// @@ -42,8 +123,6 @@ public sealed partial class DecayPlacement /// If defined, the decay function will only compute the decay function for documents with a distance greater than the defined offset. /// /// - [JsonInclude, JsonPropertyName("offset")] - [SourceConverter] public TScale? Offset { get; set; } /// @@ -51,8 +130,6 @@ public sealed partial class DecayPlacement /// The point of origin used for calculating distance. Must be given as a number for numeric field, date for date fields and geo point for geo fields. /// /// - [JsonInclude, JsonPropertyName("origin")] - [SourceConverter] public TOrigin? Origin { get; set; } /// @@ -60,7 +137,5 @@ public sealed partial class DecayPlacement /// Defines the distance from origin + offset at which the computed score will equal decay parameter. /// /// - [JsonInclude, JsonPropertyName("scale")] - [SourceConverter] public TScale? Scale { get; set; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs new file mode 100644 index 00000000000..860cb6b2492 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs @@ -0,0 +1,61 @@ +// 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. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; +using Elastic.Clients.Elasticsearch.Serverless.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; + +[JsonConverter(typeof(DistanceFeatureQueryConverter))] +public partial interface IDistanceFeatureQuery +{ + public string? Type { get; } +} + +internal sealed partial class DistanceFeatureQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IDistanceFeatureQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDistanceFeatureQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IDistanceFeatureQuery)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FieldAndFormat.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FieldAndFormat.g.cs index 65dd5cedf73..38ee336ef6b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FieldAndFormat.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FieldAndFormat.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,11 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class FieldAndFormatConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeUnmapped = System.Text.Json.JsonEncodedText.Encode("include_unmapped"); + + public override FieldAndFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propIncludeUnmapped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIncludeUnmapped.TryRead(ref reader, options, PropIncludeUnmapped)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new FieldAndFormat { Field = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldAndFormat + { + Field = propField.Value +, + Format = propFormat.Value +, + IncludeUnmapped = propIncludeUnmapped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldAndFormat value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIncludeUnmapped, value.IncludeUnmapped); + writer.WriteEndObject(); + } +} + /// /// /// A reference to a field with formatting instructions on how to return the value /// /// +[JsonConverter(typeof(FieldAndFormatConverter))] public sealed partial class FieldAndFormat { /// @@ -39,7 +104,6 @@ public sealed partial class FieldAndFormat /// Wildcard pattern. The request returns values for field names matching this pattern. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } /// @@ -47,9 +111,7 @@ public sealed partial class FieldAndFormat /// Format in which the values are returned. /// /// - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("include_unmapped")] public bool? IncludeUnmapped { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScore.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScore.g.cs index 08762e35737..27bd9c48efb 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScore.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScore.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,22 +40,29 @@ internal FunctionScore(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal FunctionScore() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } + public static FunctionScore Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore FieldValueFactor(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => new FunctionScore("field_value_factor", fieldValueFactorScoreFunction); + public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); + public static FunctionScore Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); @@ -80,137 +88,129 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class FunctionScoreConverter : JsonConverter +internal sealed partial class FunctionScoreConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionScore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropWeight = System.Text.Json.JsonEncodedText.Encode("weight"); + private static readonly System.Text.Json.JsonEncodedText VariantExp = System.Text.Json.JsonEncodedText.Encode("exp"); + private static readonly System.Text.Json.JsonEncodedText VariantFieldValueFactor = System.Text.Json.JsonEncodedText.Encode("field_value_factor"); + private static readonly System.Text.Json.JsonEncodedText VariantGauss = System.Text.Json.JsonEncodedText.Encode("gauss"); + private static readonly System.Text.Json.JsonEncodedText VariantLinear = System.Text.Json.JsonEncodedText.Encode("linear"); + private static readonly System.Text.Json.JsonEncodedText VariantRandomScore = System.Text.Json.JsonEncodedText.Encode("random_score"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptScore = System.Text.Json.JsonEncodedText.Encode("script_score"); + + public override FunctionScore Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? filterValue = default; - double? weightValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propFilter = default; + LocalJsonProperty propWeight = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "filter") + if (propFilter.TryRead(ref reader, options, PropFilter)) { - filterValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "weight") + if (propWeight.TryRead(ref reader, options, PropWeight)) { - weightValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "exp") + if (reader.ValueTextEquals(VariantExp)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExp.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "field_value_factor") + if (reader.ValueTextEquals(VariantFieldValueFactor)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFieldValueFactor.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "gauss") + if (reader.ValueTextEquals(VariantGauss)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGauss.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "linear") + if (reader.ValueTextEquals(VariantLinear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "random_score") + if (reader.ValueTextEquals(VariantRandomScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRandomScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script_score") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FunctionScore' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new FunctionScore(variantNameValue, variantValue); - result.Filter = filterValue; - result.Weight = weightValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FunctionScore + { + VariantType = variantType, + Variant = variant, + Filter = propFilter.Value +, + Weight = propWeight.Value + }; } - public override void Write(Utf8JsonWriter writer, FunctionScore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScore value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Filter is not null) - { - writer.WritePropertyName("filter"); - JsonSerializer.Serialize(writer, value.Filter, options); - } - - if (value.Weight.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("weight"); - writer.WriteNumberValue(value.Weight.Value); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "exp": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "field_value_factor": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldValueFactorScoreFunction)value.Variant, options); - break; - case "gauss": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "linear": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "random_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RandomScoreFunction)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptScoreFunction)value.Variant, options); - break; - } + case "": + break; + case "exp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction)value.Variant); + break; + case "field_value_factor": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldValueFactorScoreFunction?)value.Variant); + break; + case "gauss": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction)value.Variant); + break; + case "linear": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction)value.Variant); + break; + case "random_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RandomScoreFunction?)value.Variant); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptScoreFunction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FunctionScore)}'."); } + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropWeight, value.Weight); writer.WriteEndObject(); } } @@ -261,16 +261,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); @@ -358,16 +361,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs index d77b5de10da..514469bdf50 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,116 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class FunctionScoreQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropBoostMode = System.Text.Json.JsonEncodedText.Encode("boost_mode"); + private static readonly System.Text.Json.JsonEncodedText PropFunctions = System.Text.Json.JsonEncodedText.Encode("functions"); + private static readonly System.Text.Json.JsonEncodedText PropMaxBoost = System.Text.Json.JsonEncodedText.Encode("max_boost"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropScoreMode = System.Text.Json.JsonEncodedText.Encode("score_mode"); + + public override FunctionScoreQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue?>(options); + return new FunctionScoreQuery { Functions = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propBoostMode = default; + LocalJsonProperty?> propFunctions = default; + LocalJsonProperty propMaxBoost = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propScoreMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propBoostMode.TryRead(ref reader, options, PropBoostMode)) + { + continue; + } + + if (propFunctions.TryRead(ref reader, options, PropFunctions)) + { + continue; + } + + if (propMaxBoost.TryRead(ref reader, options, PropMaxBoost)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propScoreMode.TryRead(ref reader, options, PropScoreMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FunctionScoreQuery + { + Boost = propBoost.Value +, + BoostMode = propBoostMode.Value +, + Functions = propFunctions.Value +, + MaxBoost = propMaxBoost.Value +, + MinScore = propMinScore.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ScoreMode = propScoreMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScoreQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropBoostMode, value.BoostMode); + writer.WriteProperty(options, PropFunctions, value.Functions); + writer.WriteProperty(options, PropMaxBoost, value.MaxBoost); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropScoreMode, value.ScoreMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FunctionScoreQueryConverter))] public sealed partial class FunctionScoreQuery { /// @@ -37,7 +148,6 @@ public sealed partial class FunctionScoreQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -45,7 +155,6 @@ public sealed partial class FunctionScoreQuery /// Defines how he newly computed score is combined with the score of the query /// /// - [JsonInclude, JsonPropertyName("boost_mode")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FunctionBoostMode? BoostMode { get; set; } /// @@ -53,7 +162,6 @@ public sealed partial class FunctionScoreQuery /// One or more functions that compute a new score for each document returned by the query. /// /// - [JsonInclude, JsonPropertyName("functions")] public ICollection? Functions { get; set; } /// @@ -61,7 +169,6 @@ public sealed partial class FunctionScoreQuery /// Restricts the new score to not exceed the provided limit. /// /// - [JsonInclude, JsonPropertyName("max_boost")] public double? MaxBoost { get; set; } /// @@ -69,7 +176,6 @@ public sealed partial class FunctionScoreQuery /// Excludes documents that do not meet the provided score threshold. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -77,9 +183,7 @@ public sealed partial class FunctionScoreQuery /// A query that determines the documents for which a new score is computed. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -87,7 +191,6 @@ public sealed partial class FunctionScoreQuery /// Specifies how the computed scores are combined /// /// - [JsonInclude, JsonPropertyName("score_mode")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FunctionScoreMode? ScoreMode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(FunctionScoreQuery functionScoreQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.FunctionScore(functionScoreQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FuzzyQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FuzzyQuery.g.cs index 634c9f48cf2..6e4a127f348 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FuzzyQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/FuzzyQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,128 +28,125 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class FuzzyQueryConverter : JsonConverter +internal sealed partial class FuzzyQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override FuzzyQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropTranspositions = System.Text.Json.JsonEncodedText.Encode("transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override FuzzyQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new FuzzyQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new FuzzyQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propFuzziness = default; + LocalJsonProperty propMaxExpansions = default; + LocalJsonProperty propPrefixLength = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRewrite = default; + LocalJsonProperty propTranspositions = default; + LocalJsonProperty propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "transpositions") - { - variant.Transpositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, FuzzyQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize FuzzyQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTranspositions.TryRead(ref reader, options, PropTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Transpositions.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FuzzyQuery { - writer.WritePropertyName("transpositions"); - writer.WriteBooleanValue(value.Transpositions.Value); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + MaxExpansions = propMaxExpansions.Value +, + PrefixLength = propPrefixLength.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Transpositions = propTranspositions.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - JsonSerializer.Serialize(writer, value.Value, options); + public override void Write(System.Text.Json.Utf8JsonWriter writer, FuzzyQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropTranspositions, value.Transpositions); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -164,6 +162,10 @@ public FuzzyQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal FuzzyQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs index 3195a8c1898..7d763e1c2c3 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,90 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class GeoBoundingBoxQueryConverter : JsonConverter +internal sealed partial class GeoBoundingBoxQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoBoundingBoxQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoundingBox = System.Text.Json.JsonEncodedText.Encode("bounding_box"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValidationMethod = System.Text.Json.JsonEncodedText.Encode("validation_method"); + + public override GeoBoundingBoxQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoBoundingBoxQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoundingBox = default; + LocalJsonProperty propField = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "validation_method") - { - variant.ValidationMethod = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.BoundingBox = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoBoundingBoxQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.BoundingBox is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.BoundingBox, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryRead(ref reader, options, PropValidationMethod)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + propField.Initialized = propBoundingBox.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propBoundingBox.Value); } - if (value.ValidationMethod is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoBoundingBoxQuery { - writer.WritePropertyName("validation_method"); - JsonSerializer.Serialize(writer, value.ValidationMethod, options); - } + BoundingBox = propBoundingBox.Value +, + Field = propField.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value +, + ValidationMethod = propValidationMethod.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoBoundingBoxQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod); + writer.WriteProperty(options, value.Field, value.BoundingBox); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs index 6691e33a2f3..f0d99960ce7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,60 +28,51 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class GeoDecayFunctionConverter : JsonConverter +internal sealed partial class GeoDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, GeoDecayFunction value, JsonSerializerOptions options) + public override GeoDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty> propPlacement = default; + LocalJsonProperty propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(GeoDecayFunctionConverter))] -public sealed partial class GeoDecayFunction +public sealed partial class GeoDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } @@ -91,6 +83,8 @@ public sealed partial class GeoDecayFunction /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "geodecayfunction"; } public sealed partial class GeoDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs index 553ecc6bce7..b7a9f490725 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -public sealed partial class GeoDistanceFeatureQuery +public sealed partial class GeoDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class GeoDistanceFeatureQuery public string Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "geodistancefeaturequery"; } public sealed partial class GeoDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs index 2b3714fabf1..bd32df01021 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,110 +28,95 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class GeoDistanceQueryConverter : JsonConverter +internal sealed partial class GeoDistanceQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDistance = System.Text.Json.JsonEncodedText.Encode("distance"); + private static readonly System.Text.Json.JsonEncodedText PropDistanceType = System.Text.Json.JsonEncodedText.Encode("distance_type"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValidationMethod = System.Text.Json.JsonEncodedText.Encode("validation_method"); + + public override GeoDistanceQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDistanceQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propLocation = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propDistance = default; + LocalJsonProperty propDistanceType = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "distance") - { - variant.Distance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "distance_type") - { - variant.DistanceType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "validation_method") - { - variant.ValidationMethod = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Location = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoDistanceQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Location is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propDistance.TryRead(ref reader, options, PropDistance)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Location, options); - } + if (propDistanceType.TryRead(ref reader, options, PropDistanceType)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) + { + continue; + } - writer.WritePropertyName("distance"); - writer.WriteStringValue(value.Distance); - if (value.DistanceType is not null) - { - writer.WritePropertyName("distance_type"); - JsonSerializer.Serialize(writer, value.DistanceType, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryRead(ref reader, options, PropValidationMethod)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + propField.Initialized = propLocation.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propLocation.Value); } - if (value.ValidationMethod is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDistanceQuery { - writer.WritePropertyName("validation_method"); - JsonSerializer.Serialize(writer, value.ValidationMethod, options); - } + Field = propField.Value +, + Location = propLocation.Value +, + Boost = propBoost.Value +, + Distance = propDistance.Value +, + DistanceType = propDistanceType.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value +, + ValidationMethod = propValidationMethod.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDistance, value.Distance); + writer.WriteProperty(options, PropDistanceType, value.DistanceType); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod); + writer.WriteProperty(options, value.Field, value.Location); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs index 7bd66d932fe..d0b67c442c8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,78 +28,65 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class GeoShapeQueryConverter : JsonConverter +internal sealed partial class GeoShapeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoShapeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override GeoShapeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoShapeQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propShape = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Shape = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoShapeQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Shape is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Shape, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); + propField.Initialized = propShape.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propShape.Value); } - if (!string.IsNullOrEmpty(value.QueryName)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoShapeQuery { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Shape = propShape.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Shape); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Intervals.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Intervals.g.cs index 2fba17d43c9..1e49d6a418e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Intervals.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Intervals.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Intervals(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Intervals() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Intervals AllOf(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf intervalsAllOf) => new Intervals("all_of", intervalsAllOf); public static Intervals AnyOf(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new Intervals("any_of", intervalsAnyOf); @@ -66,107 +71,104 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsConverter : JsonConverter +internal sealed partial class IntervalsConverter : System.Text.Json.Serialization.JsonConverter { - public override Intervals Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAllOf = System.Text.Json.JsonEncodedText.Encode("all_of"); + private static readonly System.Text.Json.JsonEncodedText VariantAnyOf = System.Text.Json.JsonEncodedText.Encode("any_of"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override Intervals Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAllOf)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "all_of") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Intervals' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Intervals(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Intervals { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Intervals value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Intervals value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf?)value.Variant); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsFuzzy?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsMatch?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsPrefix?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsWildcard?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Intervals)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsFilter.g.cs index 787ad340e5d..e9534995e6f 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsFilter.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal IntervalsFilter(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IntervalsFilter() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IntervalsFilter After(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("after", intervalsContainer); public static IntervalsFilter Before(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("before", intervalsContainer); @@ -69,137 +74,140 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsFilterConverter : JsonConverter +internal sealed partial class IntervalsFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override IntervalsFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAfter = System.Text.Json.JsonEncodedText.Encode("after"); + private static readonly System.Text.Json.JsonEncodedText VariantBefore = System.Text.Json.JsonEncodedText.Encode("before"); + private static readonly System.Text.Json.JsonEncodedText VariantContainedBy = System.Text.Json.JsonEncodedText.Encode("contained_by"); + private static readonly System.Text.Json.JsonEncodedText VariantContaining = System.Text.Json.JsonEncodedText.Encode("containing"); + private static readonly System.Text.Json.JsonEncodedText VariantNotContainedBy = System.Text.Json.JsonEncodedText.Encode("not_contained_by"); + private static readonly System.Text.Json.JsonEncodedText VariantNotContaining = System.Text.Json.JsonEncodedText.Encode("not_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantNotOverlapping = System.Text.Json.JsonEncodedText.Encode("not_overlapping"); + private static readonly System.Text.Json.JsonEncodedText VariantOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override IntervalsFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAfter)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "after") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAfter.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "before") + if (reader.ValueTextEquals(VariantBefore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBefore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "contained_by") + if (reader.ValueTextEquals(VariantContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "containing") + if (reader.ValueTextEquals(VariantContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_contained_by") + if (reader.ValueTextEquals(VariantNotContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_containing") + if (reader.ValueTextEquals(VariantNotContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_overlapping") + if (reader.ValueTextEquals(VariantNotOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "overlapping") + if (reader.ValueTextEquals(VariantOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsFilter' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IntervalsFilter(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntervalsFilter { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IntervalsFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntervalsFilter value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "after": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "before": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "not_contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "not_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "not_overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Script)value.Variant, options); - break; - } + case "": + break; + case "after": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "before": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "not_contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "not_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "not_overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Intervals?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Script?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IntervalsFilter)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs index 58eac78e84c..d65da61bab7 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal IntervalsQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IntervalsQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IntervalsQuery AllOf(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf intervalsAllOf) => new IntervalsQuery("all_of", intervalsAllOf); public static IntervalsQuery AnyOf(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new IntervalsQuery("any_of", intervalsAnyOf); @@ -81,149 +86,139 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsQueryConverter : JsonConverter +internal sealed partial class IntervalsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantAllOf = System.Text.Json.JsonEncodedText.Encode("all_of"); + private static readonly System.Text.Json.JsonEncodedText VariantAnyOf = System.Text.Json.JsonEncodedText.Encode("any_of"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override IntervalsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - reader.Read(); - var fieldName = reader.GetString(); - reader.Read(); - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propField = default; + LocalJsonProperty propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") + if (propField.TryRead(ref reader, options, PropField)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "all_of") + if (reader.ValueTextEquals(VariantAllOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - reader.Read(); - var result = new IntervalsQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Field = fieldName; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntervalsQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Field = propField.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntervalsQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); writer.WriteStartObject(); - if (value.Boost.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf?)value.Variant); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsFuzzy?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsMatch?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsPrefix?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsWildcard?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IntervalsQuery)}'."); } - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } - } - - writer.WriteEndObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/LikeDocument.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/LikeDocument.g.cs index 366d3423770..ab69a4ff082 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/LikeDocument.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/LikeDocument.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,110 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class LikeDocumentConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPerFieldAnalyzer = System.Text.Json.JsonEncodedText.Encode("per_field_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override LikeDocument Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propDoc = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propId = default; + LocalJsonProperty propIndex = default; + LocalJsonProperty?> propPerFieldAnalyzer = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPerFieldAnalyzer.TryRead(ref reader, options, PropPerFieldAnalyzer)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LikeDocument + { + Doc = propDoc.Value +, + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PerFieldAnalyzer = propPerFieldAnalyzer.Value +, + Routing = propRouting.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LikeDocument value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropFields, value.Fields, typeof(FieldsMarker)); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPerFieldAnalyzer, value.PerFieldAnalyzer); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LikeDocumentConverter))] public sealed partial class LikeDocument { /// @@ -34,10 +139,7 @@ public sealed partial class LikeDocument /// A document not present in the index. /// /// - [JsonInclude, JsonPropertyName("doc")] public object? Doc { get; set; } - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -45,7 +147,6 @@ public sealed partial class LikeDocument /// ID of a document. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Serverless.Id? Id { get; set; } /// @@ -53,7 +154,6 @@ public sealed partial class LikeDocument /// Index of a document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.Serverless.IndexName? Index { get; set; } /// @@ -61,13 +161,9 @@ public sealed partial class LikeDocument /// Overrides the default analyzer. /// /// - [JsonInclude, JsonPropertyName("per_field_analyzer")] public IDictionary? PerFieldAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs index d9abed4ea45..30f93bacc18 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,164 +28,155 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class MatchBoolPrefixQueryConverter : JsonConverter +internal sealed partial class MatchBoolPrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchBoolPrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override MatchBoolPrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new MatchBoolPrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchBoolPrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propFuzziness = default; + LocalJsonProperty propFuzzyRewrite = default; + LocalJsonProperty propFuzzyTranspositions = default; + LocalJsonProperty propMaxExpansions = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propOperator = default; + LocalJsonProperty propPrefixLength = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_rewrite") - { - variant.FuzzyRewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_transpositions") - { - variant.FuzzyTranspositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "operator") - { - variant.Operator = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchBoolPrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchBoolPrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchBoolPrefixQuery + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchBoolPrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -200,6 +192,10 @@ public MatchBoolPrefixQuery(Elastic.Clients.Elasticsearch.Serverless.Field field Field = field; } + internal MatchBoolPrefixQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs index 037b01ac21b..cb344d8aa71 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,116 +28,115 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class MatchPhrasePrefixQueryConverter : JsonConverter +internal sealed partial class MatchPhrasePrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchPhrasePrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchPhrasePrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new MatchPhrasePrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchPhrasePrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propMaxExpansions = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propSlop = default; + LocalJsonProperty propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slop") - { - variant.Slop = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchPhrasePrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchPhrasePrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ZeroTermsQuery is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchPhrasePrefixQuery { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); - } + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + MaxExpansions = propMaxExpansions.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchPhrasePrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +152,10 @@ public MatchPhrasePrefixQuery(Elastic.Clients.Elasticsearch.Serverless.Field fie Field = field; } + internal MatchPhrasePrefixQuery() + { + } + /// /// /// Analyzer used to convert text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs index e19091ee3da..9acf8ddfe2d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,104 +28,105 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class MatchPhraseQueryConverter : JsonConverter +internal sealed partial class MatchPhraseQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchPhraseQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchPhraseQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new MatchPhraseQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchPhraseQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propSlop = default; + LocalJsonProperty propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slop") - { - variant.Slop = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchPhraseQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchPhraseQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ZeroTermsQuery is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchPhraseQuery { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); - } + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchPhraseQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +142,10 @@ public MatchPhraseQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal MatchPhraseQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchQuery.g.cs index 5907d2f7093..a0e716542d8 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MatchQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,200 +28,185 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class MatchQueryConverter : JsonConverter +internal sealed partial class MatchQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new MatchQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + reader.Read(); + return new MatchQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propFuzziness = default; + LocalJsonProperty propFuzzyRewrite = default; + LocalJsonProperty propFuzzyTranspositions = default; + LocalJsonProperty propLenient = default; + LocalJsonProperty propMaxExpansions = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propOperator = default; + LocalJsonProperty propPrefixLength = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "auto_generate_synonyms_phrase_query") - { - variant.AutoGenerateSynonymsPhraseQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_rewrite") - { - variant.FuzzyRewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_transpositions") - { - variant.FuzzyTranspositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lenient") - { - variant.Lenient = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "operator") - { - variant.Operator = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - if (value.AutoGenerateSynonymsPhraseQuery.HasValue) - { - writer.WritePropertyName("auto_generate_synonyms_phrase_query"); - writer.WriteBooleanValue(value.AutoGenerateSynonymsPhraseQuery.Value); - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Lenient.HasValue) - { - writer.WritePropertyName("lenient"); - writer.WriteBooleanValue(value.Lenient.Value); - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } - if (value.ZeroTermsQuery is not null) - { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchQuery + { + Analyzer = propAnalyzer.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -236,6 +222,10 @@ public MatchQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal MatchQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs index 96910cced47..2a9a3b926ce 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,230 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class MoreLikeThisQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropBoostTerms = System.Text.Json.JsonEncodedText.Encode("boost_terms"); + private static readonly System.Text.Json.JsonEncodedText PropFailOnUnsupportedField = System.Text.Json.JsonEncodedText.Encode("fail_on_unsupported_field"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropLike = System.Text.Json.JsonEncodedText.Encode("like"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDocFreq = System.Text.Json.JsonEncodedText.Encode("max_doc_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMaxQueryTerms = System.Text.Json.JsonEncodedText.Encode("max_query_terms"); + private static readonly System.Text.Json.JsonEncodedText PropMaxWordLength = System.Text.Json.JsonEncodedText.Encode("max_word_length"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocFreq = System.Text.Json.JsonEncodedText.Encode("min_doc_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMinTermFreq = System.Text.Json.JsonEncodedText.Encode("min_term_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMinWordLength = System.Text.Json.JsonEncodedText.Encode("min_word_length"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropStopWords = System.Text.Json.JsonEncodedText.Encode("stop_words"); + private static readonly System.Text.Json.JsonEncodedText PropUnlike = System.Text.Json.JsonEncodedText.Encode("unlike"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MoreLikeThisQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propBoostTerms = default; + LocalJsonProperty propFailOnUnsupportedField = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propInclude = default; + LocalJsonProperty> propLike = default; + LocalJsonProperty propMaxDocFreq = default; + LocalJsonProperty propMaxQueryTerms = default; + LocalJsonProperty propMaxWordLength = default; + LocalJsonProperty propMinDocFreq = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propMinTermFreq = default; + LocalJsonProperty propMinWordLength = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRouting = default; + LocalJsonProperty?> propStopWords = default; + LocalJsonProperty?> propUnlike = default; + LocalJsonProperty propVersion = default; + LocalJsonProperty propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propBoostTerms.TryRead(ref reader, options, PropBoostTerms)) + { + continue; + } + + if (propFailOnUnsupportedField.TryRead(ref reader, options, PropFailOnUnsupportedField)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propLike.TryRead(ref reader, options, PropLike, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like>))) + { + continue; + } + + if (propMaxDocFreq.TryRead(ref reader, options, PropMaxDocFreq)) + { + continue; + } + + if (propMaxQueryTerms.TryRead(ref reader, options, PropMaxQueryTerms)) + { + continue; + } + + if (propMaxWordLength.TryRead(ref reader, options, PropMaxWordLength)) + { + continue; + } + + if (propMinDocFreq.TryRead(ref reader, options, PropMinDocFreq)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propMinTermFreq.TryRead(ref reader, options, PropMinTermFreq)) + { + continue; + } + + if (propMinWordLength.TryRead(ref reader, options, PropMinWordLength)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propStopWords.TryRead(ref reader, options, PropStopWords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propUnlike.TryRead(ref reader, options, PropUnlike, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like>))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MoreLikeThisQuery + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + BoostTerms = propBoostTerms.Value +, + FailOnUnsupportedField = propFailOnUnsupportedField.Value +, + Fields = propFields.Value +, + Include = propInclude.Value +, + Like = propLike.Value +, + MaxDocFreq = propMaxDocFreq.Value +, + MaxQueryTerms = propMaxQueryTerms.Value +, + MaxWordLength = propMaxWordLength.Value +, + MinDocFreq = propMinDocFreq.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + MinTermFreq = propMinTermFreq.Value +, + MinWordLength = propMinWordLength.Value +, + QueryName = propQueryName.Value +, + Routing = propRouting.Value +, + StopWords = propStopWords.Value +, + Unlike = propUnlike.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MoreLikeThisQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropBoostTerms, value.BoostTerms); + writer.WriteProperty(options, PropFailOnUnsupportedField, value.FailOnUnsupportedField); + writer.WriteProperty(options, PropFields, value.Fields, typeof(FieldsMarker)); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropLike, value.Like, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like>)); + writer.WriteProperty(options, PropMaxDocFreq, value.MaxDocFreq); + writer.WriteProperty(options, PropMaxQueryTerms, value.MaxQueryTerms); + writer.WriteProperty(options, PropMaxWordLength, value.MaxWordLength); + writer.WriteProperty(options, PropMinDocFreq, value.MinDocFreq); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMinTermFreq, value.MinTermFreq); + writer.WriteProperty(options, PropMinWordLength, value.MinWordLength); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropStopWords, value.StopWords, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnlike, value.Unlike, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like>)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MoreLikeThisQueryConverter))] public sealed partial class MoreLikeThisQuery { /// @@ -35,7 +260,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to the analyzer associated with the first field in fields. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -46,7 +270,6 @@ public sealed partial class MoreLikeThisQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -56,7 +279,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to deactivated (0). /// /// - [JsonInclude, JsonPropertyName("boost_terms")] public double? BoostTerms { get; set; } /// @@ -64,7 +286,6 @@ public sealed partial class MoreLikeThisQuery /// Controls whether the query should fail (throw an exception) if any of the specified fields are not of the supported types (text or keyword). /// /// - [JsonInclude, JsonPropertyName("fail_on_unsupported_field")] public bool? FailOnUnsupportedField { get; set; } /// @@ -73,8 +294,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -82,7 +301,6 @@ public sealed partial class MoreLikeThisQuery /// Specifies whether the input documents should also be included in the search results returned. /// /// - [JsonInclude, JsonPropertyName("include")] public bool? Include { get; set; } /// @@ -90,8 +308,6 @@ public sealed partial class MoreLikeThisQuery /// Specifies free form text and/or a single or multiple documents for which you want to find similar documents. /// /// - [JsonInclude, JsonPropertyName("like")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like))] public ICollection Like { get; set; } /// @@ -99,7 +315,6 @@ public sealed partial class MoreLikeThisQuery /// The maximum document frequency above which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("max_doc_freq")] public int? MaxDocFreq { get; set; } /// @@ -107,7 +322,6 @@ public sealed partial class MoreLikeThisQuery /// The maximum number of query terms that can be selected. /// /// - [JsonInclude, JsonPropertyName("max_query_terms")] public int? MaxQueryTerms { get; set; } /// @@ -116,7 +330,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to unbounded (0). /// /// - [JsonInclude, JsonPropertyName("max_word_length")] public int? MaxWordLength { get; set; } /// @@ -124,7 +337,6 @@ public sealed partial class MoreLikeThisQuery /// The minimum document frequency below which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("min_doc_freq")] public int? MinDocFreq { get; set; } /// @@ -132,7 +344,6 @@ public sealed partial class MoreLikeThisQuery /// After the disjunctive query has been formed, this parameter controls the number of terms that must match. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -140,7 +351,6 @@ public sealed partial class MoreLikeThisQuery /// The minimum term frequency below which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("min_term_freq")] public int? MinTermFreq { get; set; } /// @@ -148,11 +358,8 @@ public sealed partial class MoreLikeThisQuery /// The minimum word length below which the terms are ignored. /// /// - [JsonInclude, JsonPropertyName("min_word_length")] public int? MinWordLength { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Serverless.Routing? Routing { get; set; } /// @@ -161,8 +368,6 @@ public sealed partial class MoreLikeThisQuery /// Any word in this set is ignored. /// /// - [JsonInclude, JsonPropertyName("stop_words")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? StopWords { get; set; } /// @@ -170,12 +375,8 @@ public sealed partial class MoreLikeThisQuery /// Used in combination with like to exclude documents that match a set of terms. /// /// - [JsonInclude, JsonPropertyName("unlike")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Like))] public ICollection? Unlike { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.Serverless.VersionType? VersionType { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(MoreLikeThisQuery moreLikeThisQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.MoreLikeThis(moreLikeThisQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs index 46c3e3aab35..d97ee54c01a 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,210 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class MultiMatchQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropTieBreaker = System.Text.Json.JsonEncodedText.Encode("tie_breaker"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MultiMatchQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFuzziness = default; + LocalJsonProperty propFuzzyRewrite = default; + LocalJsonProperty propFuzzyTranspositions = default; + LocalJsonProperty propLenient = default; + LocalJsonProperty propMaxExpansions = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propOperator = default; + LocalJsonProperty propPrefixLength = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propSlop = default; + LocalJsonProperty propTieBreaker = default; + LocalJsonProperty propType = default; + LocalJsonProperty propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } + + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } + + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } + + if (propTieBreaker.TryRead(ref reader, options, PropTieBreaker)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiMatchQuery + { + Analyzer = propAnalyzer.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Fields = propFields.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + TieBreaker = propTieBreaker.Value +, + Type = propType.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiMatchQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFields, value.Fields, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropTieBreaker, value.TieBreaker); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiMatchQueryConverter))] public sealed partial class MultiMatchQuery { /// @@ -34,7 +239,6 @@ public sealed partial class MultiMatchQuery /// Analyzer used to convert the text in the query value into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -42,7 +246,6 @@ public sealed partial class MultiMatchQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -53,7 +256,6 @@ public sealed partial class MultiMatchQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -62,8 +264,6 @@ public sealed partial class MultiMatchQuery /// Defaults to the index.query.default_field index settings, which in turn defaults to *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -71,7 +271,6 @@ public sealed partial class MultiMatchQuery /// Maximum edit distance allowed for matching. /// /// - [JsonInclude, JsonPropertyName("fuzziness")] public Elastic.Clients.Elasticsearch.Serverless.Fuzziness? Fuzziness { get; set; } /// @@ -79,7 +278,6 @@ public sealed partial class MultiMatchQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("fuzzy_rewrite")] public string? FuzzyRewrite { get; set; } /// @@ -88,7 +286,6 @@ public sealed partial class MultiMatchQuery /// Can be applied to the term subqueries constructed for all terms but the final term. /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -96,7 +293,6 @@ public sealed partial class MultiMatchQuery /// If true, format-based errors, such as providing a text query value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -104,7 +300,6 @@ public sealed partial class MultiMatchQuery /// Maximum number of terms to which the query will expand. /// /// - [JsonInclude, JsonPropertyName("max_expansions")] public int? MaxExpansions { get; set; } /// @@ -112,7 +307,6 @@ public sealed partial class MultiMatchQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -120,7 +314,6 @@ public sealed partial class MultiMatchQuery /// Boolean logic used to interpret text in the query value. /// /// - [JsonInclude, JsonPropertyName("operator")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Operator? Operator { get; set; } /// @@ -128,7 +321,6 @@ public sealed partial class MultiMatchQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("prefix_length")] public int? PrefixLength { get; set; } /// @@ -136,9 +328,7 @@ public sealed partial class MultiMatchQuery /// Text, number, boolean value or date you wish to find in the provided field. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -146,7 +336,6 @@ public sealed partial class MultiMatchQuery /// Maximum number of positions allowed between matching tokens. /// /// - [JsonInclude, JsonPropertyName("slop")] public int? Slop { get; set; } /// @@ -154,7 +343,6 @@ public sealed partial class MultiMatchQuery /// Determines how scores for each per-term blended query and scores across groups are combined. /// /// - [JsonInclude, JsonPropertyName("tie_breaker")] public double? TieBreaker { get; set; } /// @@ -162,7 +350,6 @@ public sealed partial class MultiMatchQuery /// How the multi_match query is executed internally. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TextQueryType? Type { get; set; } /// @@ -170,7 +357,6 @@ public sealed partial class MultiMatchQuery /// Indicates whether no documents are returned if the analyzer removes all tokens, such as when using a stop filter. /// /// - [JsonInclude, JsonPropertyName("zero_terms_query")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(MultiMatchQuery multiMatchQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.MultiMatch(multiMatchQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs index 66640e3d2f5..52c8e3a5cd6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,127 +28,115 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class NumberRangeQueryConverter : JsonConverter +internal sealed partial class NumberRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override NumberRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + + public override NumberRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new NumberRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propGt = default; + LocalJsonProperty propGte = default; + LocalJsonProperty propLt = default; + LocalJsonProperty propLte = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, NumberRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize NumberRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt.HasValue) - { - writer.WritePropertyName("gt"); - writer.WriteNumberValue(value.Gt.Value); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte.HasValue) - { - writer.WritePropertyName("gte"); - writer.WriteNumberValue(value.Gte.Value); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt.HasValue) - { - writer.WritePropertyName("lt"); - writer.WriteNumberValue(value.Lt.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte.HasValue) - { - writer.WritePropertyName("lte"); - writer.WriteNumberValue(value.Lte.Value); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Relation is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NumberRangeQuery { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumberRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(NumberRangeQueryConverter))] -public sealed partial class NumberRangeQuery +public sealed partial class NumberRangeQuery : IRangeQuery { public NumberRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) { @@ -156,6 +145,10 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal NumberRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +195,8 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) /// /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "numberrangequery"; } public sealed partial class NumberRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs index c8fb77dbb14..09492061b9d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,60 +28,51 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class NumericDecayFunctionConverter : JsonConverter +internal sealed partial class NumericDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override NumericDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new NumericDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, NumericDecayFunction value, JsonSerializerOptions options) + public override NumericDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty> propPlacement = default; + LocalJsonProperty propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NumericDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumericDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(NumericDecayFunctionConverter))] -public sealed partial class NumericDecayFunction +public sealed partial class NumericDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } @@ -91,6 +83,8 @@ public sealed partial class NumericDecayFunction /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "numericdecayfunction"; } public sealed partial class NumericDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PinnedQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PinnedQuery.g.cs index 3cee9827032..5429314b790 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PinnedQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PinnedQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal PinnedQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal PinnedQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static PinnedQuery Docs(IReadOnlyCollection pinnedDoc) => new PinnedQuery("docs", pinnedDoc); public static PinnedQuery Ids(IReadOnlyCollection id) => new PinnedQuery("ids", id); @@ -83,111 +88,91 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class PinnedQueryConverter : JsonConverter +internal sealed partial class PinnedQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override PinnedQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropOrganic = System.Text.Json.JsonEncodedText.Encode("organic"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + private static readonly System.Text.Json.JsonEncodedText VariantIds = System.Text.Json.JsonEncodedText.Encode("ids"); - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query organicValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override PinnedQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propOrganic = default; + LocalJsonProperty propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") - { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "organic") + if (propOrganic.TryRead(ref reader, options, PropOrganic)) { - organicValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "docs") + if (reader.ValueTextEquals(VariantDocs)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDocs.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - if (propertyName == "ids") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'PinnedQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new PinnedQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Organic = organicValue; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PinnedQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Organic = propOrganic.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, PinnedQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PinnedQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Boost.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.Organic is not null) - { - writer.WritePropertyName("organic"); - JsonSerializer.Serialize(writer, value.Organic, options); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "docs": - JsonSerializer.Serialize>(writer, (IReadOnlyCollection)value.Variant, options); - break; - case "ids": - JsonSerializer.Serialize>(writer, (IReadOnlyCollection)value.Variant, options); - break; - } + case "": + break; + case "docs": + writer.WriteProperty(options, value.VariantType, (ICollection?)value.Variant); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (ICollection?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(PinnedQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropOrganic, value.Organic); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PrefixQuery.g.cs index f808632a013..16f9ad937ef 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/PrefixQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,92 +28,95 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class PrefixQueryConverter : JsonConverter +internal sealed partial class PrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override PrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override PrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new PrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new PrefixQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCaseInsensitive = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRewrite = default; + LocalJsonProperty propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, PrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize PrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Rewrite)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PrefixQuery { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + public override void Write(System.Text.Json.Utf8JsonWriter writer, PrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -128,6 +132,10 @@ public PrefixQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal PrefixQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Query.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Query.g.cs index 344d8300e1b..8771568a62e 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Query.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/Query.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -44,18 +45,23 @@ internal Query(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Query() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Query Bool(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoolQuery boolQuery) => new Query("bool", boolQuery); public static Query Boosting(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoostingQuery boostingQuery) => new Query("boosting", boostingQuery); public static Query CombinedFields(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.CombinedFieldsQuery combinedFieldsQuery) => new Query("combined_fields", combinedFieldsQuery); public static Query ConstantScore(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ConstantScoreQuery constantScoreQuery) => new Query("constant_score", constantScoreQuery); public static Query DisMax(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DisMaxQuery disMaxQuery) => new Query("dis_max", disMaxQuery); + public static Query DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); @@ -84,6 +90,7 @@ internal Query(string variantName, object variant) public static Query Pinned(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PinnedQuery pinnedQuery) => new Query("pinned", pinnedQuery); public static Query Prefix(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PrefixQuery prefixQuery) => new Query("prefix", prefixQuery); public static Query QueryString(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryStringQuery queryStringQuery) => new Query("query_string", queryStringQuery); + public static Query Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumberRangeQuery rangeQuery) => new Query("range", rangeQuery); @@ -126,607 +133,704 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class QueryConverter : JsonConverter +internal sealed partial class QueryConverter : System.Text.Json.Serialization.JsonConverter { - public override Query Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantBool = System.Text.Json.JsonEncodedText.Encode("bool"); + private static readonly System.Text.Json.JsonEncodedText VariantBoosting = System.Text.Json.JsonEncodedText.Encode("boosting"); + private static readonly System.Text.Json.JsonEncodedText VariantCombinedFields = System.Text.Json.JsonEncodedText.Encode("combined_fields"); + private static readonly System.Text.Json.JsonEncodedText VariantConstantScore = System.Text.Json.JsonEncodedText.Encode("constant_score"); + private static readonly System.Text.Json.JsonEncodedText VariantDisMax = System.Text.Json.JsonEncodedText.Encode("dis_max"); + private static readonly System.Text.Json.JsonEncodedText VariantDistanceFeature = System.Text.Json.JsonEncodedText.Encode("distance_feature"); + private static readonly System.Text.Json.JsonEncodedText VariantExists = System.Text.Json.JsonEncodedText.Encode("exists"); + private static readonly System.Text.Json.JsonEncodedText VariantFunctionScore = System.Text.Json.JsonEncodedText.Encode("function_score"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoBoundingBox = System.Text.Json.JsonEncodedText.Encode("geo_bounding_box"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoDistance = System.Text.Json.JsonEncodedText.Encode("geo_distance"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + private static readonly System.Text.Json.JsonEncodedText VariantHasChild = System.Text.Json.JsonEncodedText.Encode("has_child"); + private static readonly System.Text.Json.JsonEncodedText VariantHasParent = System.Text.Json.JsonEncodedText.Encode("has_parent"); + private static readonly System.Text.Json.JsonEncodedText VariantIds = System.Text.Json.JsonEncodedText.Encode("ids"); + private static readonly System.Text.Json.JsonEncodedText VariantIntervals = System.Text.Json.JsonEncodedText.Encode("intervals"); + private static readonly System.Text.Json.JsonEncodedText VariantKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchAll = System.Text.Json.JsonEncodedText.Encode("match_all"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchBoolPrefix = System.Text.Json.JsonEncodedText.Encode("match_bool_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchNone = System.Text.Json.JsonEncodedText.Encode("match_none"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchPhrase = System.Text.Json.JsonEncodedText.Encode("match_phrase"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchPhrasePrefix = System.Text.Json.JsonEncodedText.Encode("match_phrase_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantMoreLikeThis = System.Text.Json.JsonEncodedText.Encode("more_like_this"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiMatch = System.Text.Json.JsonEncodedText.Encode("multi_match"); + private static readonly System.Text.Json.JsonEncodedText VariantNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText VariantParentId = System.Text.Json.JsonEncodedText.Encode("parent_id"); + private static readonly System.Text.Json.JsonEncodedText VariantPercolate = System.Text.Json.JsonEncodedText.Encode("percolate"); + private static readonly System.Text.Json.JsonEncodedText VariantPinned = System.Text.Json.JsonEncodedText.Encode("pinned"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantQueryString = System.Text.Json.JsonEncodedText.Encode("query_string"); + private static readonly System.Text.Json.JsonEncodedText VariantRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText VariantRankFeature = System.Text.Json.JsonEncodedText.Encode("rank_feature"); + private static readonly System.Text.Json.JsonEncodedText VariantRawJson = System.Text.Json.JsonEncodedText.Encode("raw_json"); + private static readonly System.Text.Json.JsonEncodedText VariantRegexp = System.Text.Json.JsonEncodedText.Encode("regexp"); + private static readonly System.Text.Json.JsonEncodedText VariantRule = System.Text.Json.JsonEncodedText.Encode("rule"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptScore = System.Text.Json.JsonEncodedText.Encode("script_score"); + private static readonly System.Text.Json.JsonEncodedText VariantSemantic = System.Text.Json.JsonEncodedText.Encode("semantic"); + private static readonly System.Text.Json.JsonEncodedText VariantShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText VariantSimpleQueryString = System.Text.Json.JsonEncodedText.Encode("simple_query_string"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanContaining = System.Text.Json.JsonEncodedText.Encode("span_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFieldMasking = System.Text.Json.JsonEncodedText.Encode("span_field_masking"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFirst = System.Text.Json.JsonEncodedText.Encode("span_first"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanMulti = System.Text.Json.JsonEncodedText.Encode("span_multi"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNear = System.Text.Json.JsonEncodedText.Encode("span_near"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNot = System.Text.Json.JsonEncodedText.Encode("span_not"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanOr = System.Text.Json.JsonEncodedText.Encode("span_or"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanTerm = System.Text.Json.JsonEncodedText.Encode("span_term"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanWithin = System.Text.Json.JsonEncodedText.Encode("span_within"); + private static readonly System.Text.Json.JsonEncodedText VariantSparseVector = System.Text.Json.JsonEncodedText.Encode("sparse_vector"); + private static readonly System.Text.Json.JsonEncodedText VariantTerm = System.Text.Json.JsonEncodedText.Encode("term"); + private static readonly System.Text.Json.JsonEncodedText VariantTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText VariantTermsSet = System.Text.Json.JsonEncodedText.Encode("terms_set"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + private static readonly System.Text.Json.JsonEncodedText VariantWrapper = System.Text.Json.JsonEncodedText.Encode("wrapper"); + + public override Query Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantBool)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bool") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBool.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "boosting") + if (reader.ValueTextEquals(VariantBoosting)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoosting.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "combined_fields") + if (reader.ValueTextEquals(VariantCombinedFields)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCombinedFields.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "constant_score") + if (reader.ValueTextEquals(VariantConstantScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConstantScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dis_max") + if (reader.ValueTextEquals(VariantDisMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDisMax.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "distance_feature") + if (reader.ValueTextEquals(VariantDistanceFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDistanceFeature.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "exists") + if (reader.ValueTextEquals(VariantExists)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExists.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "function_score") + if (reader.ValueTextEquals(VariantFunctionScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFunctionScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_bounding_box") + if (reader.ValueTextEquals(VariantGeoBoundingBox)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBoundingBox.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_shape") + if (reader.ValueTextEquals(VariantGeoShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoShape.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "has_child") + if (reader.ValueTextEquals(VariantHasChild)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasChild.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "has_parent") + if (reader.ValueTextEquals(VariantHasParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasParent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ids") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "intervals") + if (reader.ValueTextEquals(VariantIntervals)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIntervals.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "knn") + if (reader.ValueTextEquals(VariantKnn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_all") + if (reader.ValueTextEquals(VariantMatchAll)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchAll.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_bool_prefix") + if (reader.ValueTextEquals(VariantMatchBoolPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchBoolPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_none") + if (reader.ValueTextEquals(VariantMatchNone)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchNone.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_phrase") + if (reader.ValueTextEquals(VariantMatchPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_phrase_prefix") + if (reader.ValueTextEquals(VariantMatchPhrasePrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrasePrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "more_like_this") + if (reader.ValueTextEquals(VariantMoreLikeThis)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMoreLikeThis.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_match") + if (reader.ValueTextEquals(VariantMultiMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "parent_id") + if (reader.ValueTextEquals(VariantParentId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParentId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percolate") + if (reader.ValueTextEquals(VariantPercolate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercolate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pinned") + if (reader.ValueTextEquals(VariantPinned)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPinned.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "query_string") + if (reader.ValueTextEquals(VariantQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rank_feature") + if (reader.ValueTextEquals(VariantRankFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRankFeature.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "raw_json") + if (reader.ValueTextEquals(VariantRawJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRawJson.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regexp") + if (reader.ValueTextEquals(VariantRegexp)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegexp.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script_score") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "semantic") + if (reader.ValueTextEquals(VariantSemantic)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSemantic.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "shape") + if (reader.ValueTextEquals(VariantShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantShape.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "simple_query_string") + if (reader.ValueTextEquals(VariantSimpleQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSimpleQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_containing") + if (reader.ValueTextEquals(VariantSpanContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_within") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sparse_vector") + if (reader.ValueTextEquals(VariantSparseVector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSparseVector.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "term") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms_set") + if (reader.ValueTextEquals(VariantTermsSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTermsSet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wrapper") + if (reader.ValueTextEquals(VariantWrapper)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWrapper.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Query' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Query(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Query { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Query value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Query value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "bool": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoolQuery)value.Variant, options); - break; - case "boosting": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoostingQuery)value.Variant, options); - break; - case "combined_fields": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.CombinedFieldsQuery)value.Variant, options); - break; - case "constant_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ConstantScoreQuery)value.Variant, options); - break; - case "dis_max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DisMaxQuery)value.Variant, options); - break; - case "distance_feature": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "exists": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ExistsQuery)value.Variant, options); - break; - case "function_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FunctionScoreQuery)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FuzzyQuery)value.Variant, options); - break; - case "geo_bounding_box": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoBoundingBoxQuery)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceQuery)value.Variant, options); - break; - case "geo_shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoShapeQuery)value.Variant, options); - break; - case "has_child": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.HasChildQuery)value.Variant, options); - break; - case "has_parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.HasParentQuery)value.Variant, options); - break; - case "ids": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IdsQuery)value.Variant, options); - break; - case "intervals": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsQuery)value.Variant, options); - break; - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.KnnQuery)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchQuery)value.Variant, options); - break; - case "match_all": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchAllQuery)value.Variant, options); - break; - case "match_bool_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchBoolPrefixQuery)value.Variant, options); - break; - case "match_none": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchNoneQuery)value.Variant, options); - break; - case "match_phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchPhraseQuery)value.Variant, options); - break; - case "match_phrase_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchPhrasePrefixQuery)value.Variant, options); - break; - case "more_like_this": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MoreLikeThisQuery)value.Variant, options); - break; - case "multi_match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiMatchQuery)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NestedQuery)value.Variant, options); - break; - case "parent_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ParentIdQuery)value.Variant, options); - break; - case "percolate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PercolateQuery)value.Variant, options); - break; - case "pinned": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PinnedQuery)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PrefixQuery)value.Variant, options); - break; - case "query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryStringQuery)value.Variant, options); - break; - case "range": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "rank_feature": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RankFeatureQuery)value.Variant, options); - break; - case "raw_json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RawJsonQuery)value.Variant, options); - break; - case "regexp": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RegexpQuery)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RuleQuery)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptQuery)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptScoreQuery)value.Variant, options); - break; - case "semantic": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SemanticQuery)value.Variant, options); - break; - case "shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ShapeQuery)value.Variant, options); - break; - case "simple_query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SimpleQueryStringQuery)value.Variant, options); - break; - case "span_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFirstQuery)value.Variant, options); - break; - case "span_multi": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - case "sparse_vector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SparseVectorQuery)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermQuery)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermsQuery)value.Variant, options); - break; - case "terms_set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermsSetQuery)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.WildcardQuery)value.Variant, options); - break; - case "wrapper": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.WrapperQuery)value.Variant, options); - break; - } + case "": + break; + case "bool": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoolQuery?)value.Variant); + break; + case "boosting": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.BoostingQuery?)value.Variant); + break; + case "combined_fields": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.CombinedFieldsQuery?)value.Variant); + break; + case "constant_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ConstantScoreQuery?)value.Variant); + break; + case "dis_max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DisMaxQuery?)value.Variant); + break; + case "distance_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDistanceFeatureQuery)value.Variant); + break; + case "exists": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ExistsQuery?)value.Variant); + break; + case "function_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FunctionScoreQuery?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.FuzzyQuery?)value.Variant); + break; + case "geo_bounding_box": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoBoundingBoxQuery?)value.Variant); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceQuery?)value.Variant); + break; + case "geo_shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoShapeQuery?)value.Variant); + break; + case "has_child": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.HasChildQuery?)value.Variant); + break; + case "has_parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.HasParentQuery?)value.Variant); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IdsQuery?)value.Variant); + break; + case "intervals": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IntervalsQuery?)value.Variant); + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.KnnQuery?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchQuery?)value.Variant); + break; + case "match_all": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchAllQuery?)value.Variant); + break; + case "match_bool_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchBoolPrefixQuery?)value.Variant); + break; + case "match_none": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchNoneQuery?)value.Variant); + break; + case "match_phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchPhraseQuery?)value.Variant); + break; + case "match_phrase_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MatchPhrasePrefixQuery?)value.Variant); + break; + case "more_like_this": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MoreLikeThisQuery?)value.Variant); + break; + case "multi_match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiMatchQuery?)value.Variant); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NestedQuery?)value.Variant); + break; + case "parent_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ParentIdQuery?)value.Variant); + break; + case "percolate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PercolateQuery?)value.Variant); + break; + case "pinned": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PinnedQuery?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.PrefixQuery?)value.Variant); + break; + case "query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryStringQuery?)value.Variant); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IRangeQuery)value.Variant); + break; + case "rank_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RankFeatureQuery?)value.Variant); + break; + case "raw_json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RawJsonQuery?)value.Variant); + break; + case "regexp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RegexpQuery?)value.Variant); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RuleQuery?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptQuery?)value.Variant); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ScriptScoreQuery?)value.Variant); + break; + case "semantic": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SemanticQuery?)value.Variant); + break; + case "shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.ShapeQuery?)value.Variant); + break; + case "simple_query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SimpleQueryStringQuery?)value.Variant); + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanContainingQuery?)value.Variant); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFieldMaskingQuery?)value.Variant); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFirstQuery?)value.Variant); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanMultiTermQuery?)value.Variant); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNearQuery?)value.Variant); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNotQuery?)value.Variant); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanOrQuery?)value.Variant); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanTermQuery?)value.Variant); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanWithinQuery?)value.Variant); + break; + case "sparse_vector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SparseVectorQuery?)value.Variant); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermQuery?)value.Variant); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermsQuery?)value.Variant); + break; + case "terms_set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermsSetQuery?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.WildcardQuery?)value.Variant); + break; + case "wrapper": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.WrapperQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Query)}'."); } writer.WriteEndObject(); @@ -774,6 +878,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action> configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action> configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -827,6 +932,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action> configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action> configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); @@ -940,6 +1046,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -993,6 +1100,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/QueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/QueryStringQuery.g.cs index 0e3a26c5163..a7a7c9eb8c6 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/QueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/QueryStringQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,300 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class QueryStringQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLeadingWildcard = System.Text.Json.JsonEncodedText.Encode("allow_leading_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzeWildcard = System.Text.Json.JsonEncodedText.Encode("analyze_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultField = System.Text.Json.JsonEncodedText.Encode("default_field"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultOperator = System.Text.Json.JsonEncodedText.Encode("default_operator"); + private static readonly System.Text.Json.JsonEncodedText PropEnablePositionIncrements = System.Text.Json.JsonEncodedText.Encode("enable_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropEscape = System.Text.Json.JsonEncodedText.Encode("escape"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyMaxExpansions = System.Text.Json.JsonEncodedText.Encode("fuzzy_max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyPrefixLength = System.Text.Json.JsonEncodedText.Encode("fuzzy_prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDeterminizedStates = System.Text.Json.JsonEncodedText.Encode("max_determinized_states"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropPhraseSlop = System.Text.Json.JsonEncodedText.Encode("phrase_slop"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteFieldSuffix = System.Text.Json.JsonEncodedText.Encode("quote_field_suffix"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropTieBreaker = System.Text.Json.JsonEncodedText.Encode("tie_breaker"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override QueryStringQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAllowLeadingWildcard = default; + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propAnalyzeWildcard = default; + LocalJsonProperty propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propDefaultField = default; + LocalJsonProperty propDefaultOperator = default; + LocalJsonProperty propEnablePositionIncrements = default; + LocalJsonProperty propEscape = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFuzziness = default; + LocalJsonProperty propFuzzyMaxExpansions = default; + LocalJsonProperty propFuzzyPrefixLength = default; + LocalJsonProperty propFuzzyRewrite = default; + LocalJsonProperty propFuzzyTranspositions = default; + LocalJsonProperty propLenient = default; + LocalJsonProperty propMaxDeterminizedStates = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propPhraseSlop = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propQuoteAnalyzer = default; + LocalJsonProperty propQuoteFieldSuffix = default; + LocalJsonProperty propRewrite = default; + LocalJsonProperty propTieBreaker = default; + LocalJsonProperty propTimeZone = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLeadingWildcard.TryRead(ref reader, options, PropAllowLeadingWildcard)) + { + continue; + } + + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAnalyzeWildcard.TryRead(ref reader, options, PropAnalyzeWildcard)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propDefaultField.TryRead(ref reader, options, PropDefaultField)) + { + continue; + } + + if (propDefaultOperator.TryRead(ref reader, options, PropDefaultOperator)) + { + continue; + } + + if (propEnablePositionIncrements.TryRead(ref reader, options, PropEnablePositionIncrements)) + { + continue; + } + + if (propEscape.TryRead(ref reader, options, PropEscape)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } + + if (propFuzzyMaxExpansions.TryRead(ref reader, options, PropFuzzyMaxExpansions)) + { + continue; + } + + if (propFuzzyPrefixLength.TryRead(ref reader, options, PropFuzzyPrefixLength)) + { + continue; + } + + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMaxDeterminizedStates.TryRead(ref reader, options, PropMaxDeterminizedStates)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propPhraseSlop.TryRead(ref reader, options, PropPhraseSlop)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQuoteAnalyzer.TryRead(ref reader, options, PropQuoteAnalyzer)) + { + continue; + } + + if (propQuoteFieldSuffix.TryRead(ref reader, options, PropQuoteFieldSuffix)) + { + continue; + } + + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } + + if (propTieBreaker.TryRead(ref reader, options, PropTieBreaker)) + { + continue; + } + + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryStringQuery + { + AllowLeadingWildcard = propAllowLeadingWildcard.Value +, + Analyzer = propAnalyzer.Value +, + AnalyzeWildcard = propAnalyzeWildcard.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + DefaultField = propDefaultField.Value +, + DefaultOperator = propDefaultOperator.Value +, + EnablePositionIncrements = propEnablePositionIncrements.Value +, + Escape = propEscape.Value +, + Fields = propFields.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyMaxExpansions = propFuzzyMaxExpansions.Value +, + FuzzyPrefixLength = propFuzzyPrefixLength.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxDeterminizedStates = propMaxDeterminizedStates.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + PhraseSlop = propPhraseSlop.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + QuoteAnalyzer = propQuoteAnalyzer.Value +, + QuoteFieldSuffix = propQuoteFieldSuffix.Value +, + Rewrite = propRewrite.Value +, + TieBreaker = propTieBreaker.Value +, + TimeZone = propTimeZone.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryStringQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLeadingWildcard, value.AllowLeadingWildcard); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAnalyzeWildcard, value.AnalyzeWildcard); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDefaultField, value.DefaultField); + writer.WriteProperty(options, PropDefaultOperator, value.DefaultOperator); + writer.WriteProperty(options, PropEnablePositionIncrements, value.EnablePositionIncrements); + writer.WriteProperty(options, PropEscape, value.Escape); + writer.WriteProperty(options, PropFields, value.Fields, typeof(FieldsMarker)); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyMaxExpansions, value.FuzzyMaxExpansions); + writer.WriteProperty(options, PropFuzzyPrefixLength, value.FuzzyPrefixLength); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxDeterminizedStates, value.MaxDeterminizedStates); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropPhraseSlop, value.PhraseSlop); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQuoteAnalyzer, value.QuoteAnalyzer); + writer.WriteProperty(options, PropQuoteFieldSuffix, value.QuoteFieldSuffix); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropTieBreaker, value.TieBreaker); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryStringQueryConverter))] public sealed partial class QueryStringQuery { /// @@ -34,7 +329,6 @@ public sealed partial class QueryStringQuery /// If true, the wildcard characters * and ? are allowed as the first character of the query string. /// /// - [JsonInclude, JsonPropertyName("allow_leading_wildcard")] public bool? AllowLeadingWildcard { get; set; } /// @@ -42,7 +336,6 @@ public sealed partial class QueryStringQuery /// Analyzer used to convert text in the query string into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -50,7 +343,6 @@ public sealed partial class QueryStringQuery /// If true, the query attempts to analyze wildcard terms in the query string. /// /// - [JsonInclude, JsonPropertyName("analyze_wildcard")] public bool? AnalyzeWildcard { get; set; } /// @@ -58,7 +350,6 @@ public sealed partial class QueryStringQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -69,7 +360,6 @@ public sealed partial class QueryStringQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -79,7 +369,6 @@ public sealed partial class QueryStringQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("default_field")] public Elastic.Clients.Elasticsearch.Serverless.Field? DefaultField { get; set; } /// @@ -87,7 +376,6 @@ public sealed partial class QueryStringQuery /// Default boolean logic used to interpret text in the query string if no operators are specified. /// /// - [JsonInclude, JsonPropertyName("default_operator")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Operator? DefaultOperator { get; set; } /// @@ -95,9 +383,7 @@ public sealed partial class QueryStringQuery /// If true, enable position increments in queries constructed from a query_string search. /// /// - [JsonInclude, JsonPropertyName("enable_position_increments")] public bool? EnablePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("escape")] public bool? Escape { get; set; } /// @@ -105,8 +391,6 @@ public sealed partial class QueryStringQuery /// Array of fields to search. Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -114,7 +398,6 @@ public sealed partial class QueryStringQuery /// Maximum edit distance allowed for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzziness")] public Elastic.Clients.Elasticsearch.Serverless.Fuzziness? Fuzziness { get; set; } /// @@ -122,7 +405,6 @@ public sealed partial class QueryStringQuery /// Maximum number of terms to which the query expands for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_max_expansions")] public int? FuzzyMaxExpansions { get; set; } /// @@ -130,7 +412,6 @@ public sealed partial class QueryStringQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_prefix_length")] public int? FuzzyPrefixLength { get; set; } /// @@ -138,7 +419,6 @@ public sealed partial class QueryStringQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("fuzzy_rewrite")] public string? FuzzyRewrite { get; set; } /// @@ -146,7 +426,6 @@ public sealed partial class QueryStringQuery /// If true, edits for fuzzy matching include transpositions of two adjacent characters (for example, ab to ba). /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -154,7 +433,6 @@ public sealed partial class QueryStringQuery /// If true, format-based errors, such as providing a text value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -162,7 +440,6 @@ public sealed partial class QueryStringQuery /// Maximum number of automaton states required for the query. /// /// - [JsonInclude, JsonPropertyName("max_determinized_states")] public int? MaxDeterminizedStates { get; set; } /// @@ -170,7 +447,6 @@ public sealed partial class QueryStringQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -178,7 +454,6 @@ public sealed partial class QueryStringQuery /// Maximum number of positions allowed between matching tokens for phrases. /// /// - [JsonInclude, JsonPropertyName("phrase_slop")] public double? PhraseSlop { get; set; } /// @@ -186,9 +461,7 @@ public sealed partial class QueryStringQuery /// Query string you wish to parse and use for search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -197,7 +470,6 @@ public sealed partial class QueryStringQuery /// For quoted text, this parameter overrides the analyzer specified in the analyzer parameter. /// /// - [JsonInclude, JsonPropertyName("quote_analyzer")] public string? QuoteAnalyzer { get; set; } /// @@ -206,7 +478,6 @@ public sealed partial class QueryStringQuery /// You can use this suffix to use a different analysis method for exact matches. /// /// - [JsonInclude, JsonPropertyName("quote_field_suffix")] public string? QuoteFieldSuffix { get; set; } /// @@ -214,7 +485,6 @@ public sealed partial class QueryStringQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("rewrite")] public string? Rewrite { get; set; } /// @@ -222,7 +492,6 @@ public sealed partial class QueryStringQuery /// How to combine the queries generated from the individual search terms in the resulting dis_max query. /// /// - [JsonInclude, JsonPropertyName("tie_breaker")] public double? TieBreaker { get; set; } /// @@ -230,7 +499,6 @@ public sealed partial class QueryStringQuery /// Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query string to UTC. /// /// - [JsonInclude, JsonPropertyName("time_zone")] public string? TimeZone { get; set; } /// @@ -238,7 +506,6 @@ public sealed partial class QueryStringQuery /// Determines how the query matches and scores documents. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TextQueryType? Type { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(QueryStringQuery queryStringQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.QueryString(queryStringQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RangeQuery.g.cs new file mode 100644 index 00000000000..3be088cbeff --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RangeQuery.g.cs @@ -0,0 +1,64 @@ +// 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. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; +using Elastic.Clients.Elasticsearch.Serverless.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; + +[JsonConverter(typeof(RangeQueryConverter))] +public partial interface IRangeQuery +{ + public string? Type { get; } +} + +internal sealed partial class RangeQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DateRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.NumberRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.TermRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.Serverless.QueryDsl.UntypedRangeQuery v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IRangeQuery)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RegexpQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RegexpQuery.g.cs index 7f6db6dfaec..905d16c0561 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RegexpQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/RegexpQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,116 +28,115 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class RegexpQueryConverter : JsonConverter +internal sealed partial class RegexpQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override RegexpQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDeterminizedStates = System.Text.Json.JsonEncodedText.Encode("max_determinized_states"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override RegexpQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new RegexpQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new RegexpQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCaseInsensitive = default; + LocalJsonProperty propFlags = default; + LocalJsonProperty propMaxDeterminizedStates = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRewrite = default; + LocalJsonProperty propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "flags") - { - variant.Flags = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_determinized_states") - { - variant.MaxDeterminizedStates = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, RegexpQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize RegexpQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propMaxDeterminizedStates.TryRead(ref reader, options, PropMaxDeterminizedStates)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Flags)) - { - writer.WritePropertyName("flags"); - writer.WriteStringValue(value.Flags); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.MaxDeterminizedStates.HasValue) - { - writer.WritePropertyName("max_determinized_states"); - writer.WriteNumberValue(value.MaxDeterminizedStates.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Rewrite)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RegexpQuery { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + Flags = propFlags.Value +, + MaxDeterminizedStates = propMaxDeterminizedStates.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + public override void Write(System.Text.Json.Utf8JsonWriter writer, RegexpQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropMaxDeterminizedStates, value.MaxDeterminizedStates); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +152,10 @@ public RegexpQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal RegexpQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/ShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/ShapeQuery.g.cs index 4d2e827716e..e1b1dd81e86 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/ShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/ShapeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,78 +28,65 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class ShapeQueryConverter : JsonConverter +internal sealed partial class ShapeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override ShapeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override ShapeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new ShapeQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propShape = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propIgnoreUnmapped = default; + LocalJsonProperty propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Shape = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, ShapeQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Shape is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Shape, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); + propField.Initialized = propShape.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propShape.Value); } - if (!string.IsNullOrEmpty(value.QueryName)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShapeQuery { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Shape = propShape.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Shape); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs index a8928659067..0c5d66039fd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,180 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; +internal sealed partial class SimpleQueryStringQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzeWildcard = System.Text.Json.JsonEncodedText.Encode("analyze_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultOperator = System.Text.Json.JsonEncodedText.Encode("default_operator"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyMaxExpansions = System.Text.Json.JsonEncodedText.Encode("fuzzy_max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyPrefixLength = System.Text.Json.JsonEncodedText.Encode("fuzzy_prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteFieldSuffix = System.Text.Json.JsonEncodedText.Encode("quote_field_suffix"); + + public override SimpleQueryStringQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propAnalyzer = default; + LocalJsonProperty propAnalyzeWildcard = default; + LocalJsonProperty propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propDefaultOperator = default; + LocalJsonProperty propFields = default; + LocalJsonProperty propFlags = default; + LocalJsonProperty propFuzzyMaxExpansions = default; + LocalJsonProperty propFuzzyPrefixLength = default; + LocalJsonProperty propFuzzyTranspositions = default; + LocalJsonProperty propLenient = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propQuoteFieldSuffix = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAnalyzeWildcard.TryRead(ref reader, options, PropAnalyzeWildcard)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propDefaultOperator.TryRead(ref reader, options, PropDefaultOperator)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } + + if (propFuzzyMaxExpansions.TryRead(ref reader, options, PropFuzzyMaxExpansions)) + { + continue; + } + + if (propFuzzyPrefixLength.TryRead(ref reader, options, PropFuzzyPrefixLength)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQuoteFieldSuffix.TryRead(ref reader, options, PropQuoteFieldSuffix)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimpleQueryStringQuery + { + Analyzer = propAnalyzer.Value +, + AnalyzeWildcard = propAnalyzeWildcard.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + DefaultOperator = propDefaultOperator.Value +, + Fields = propFields.Value +, + Flags = propFlags.Value +, + FuzzyMaxExpansions = propFuzzyMaxExpansions.Value +, + FuzzyPrefixLength = propFuzzyPrefixLength.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + QuoteFieldSuffix = propQuoteFieldSuffix.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimpleQueryStringQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAnalyzeWildcard, value.AnalyzeWildcard); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDefaultOperator, value.DefaultOperator); + writer.WriteProperty(options, PropFields, value.Fields, typeof(FieldsMarker)); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropFuzzyMaxExpansions, value.FuzzyMaxExpansions); + writer.WriteProperty(options, PropFuzzyPrefixLength, value.FuzzyPrefixLength); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQuoteFieldSuffix, value.QuoteFieldSuffix); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimpleQueryStringQueryConverter))] public sealed partial class SimpleQueryStringQuery { /// @@ -34,7 +209,6 @@ public sealed partial class SimpleQueryStringQuery /// Analyzer used to convert text in the query string into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -42,7 +216,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, the query attempts to analyze wildcard terms in the query string. /// /// - [JsonInclude, JsonPropertyName("analyze_wildcard")] public bool? AnalyzeWildcard { get; set; } /// @@ -50,7 +223,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, the parser creates a match_phrase query for each multi-position token. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -61,7 +233,6 @@ public sealed partial class SimpleQueryStringQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -69,7 +240,6 @@ public sealed partial class SimpleQueryStringQuery /// Default boolean logic used to interpret text in the query string if no operators are specified. /// /// - [JsonInclude, JsonPropertyName("default_operator")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Operator? DefaultOperator { get; set; } /// @@ -80,8 +250,6 @@ public sealed partial class SimpleQueryStringQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Serverless.Fields? Fields { get; set; } /// @@ -89,7 +257,6 @@ public sealed partial class SimpleQueryStringQuery /// List of enabled operators for the simple query string syntax. /// /// - [JsonInclude, JsonPropertyName("flags")] public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SimpleQueryStringFlag? Flags { get; set; } /// @@ -97,7 +264,6 @@ public sealed partial class SimpleQueryStringQuery /// Maximum number of terms to which the query expands for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_max_expansions")] public int? FuzzyMaxExpansions { get; set; } /// @@ -105,7 +271,6 @@ public sealed partial class SimpleQueryStringQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_prefix_length")] public int? FuzzyPrefixLength { get; set; } /// @@ -113,7 +278,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, edits for fuzzy matching include transpositions of two adjacent characters (for example, ab to ba). /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -121,7 +285,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, format-based errors, such as providing a text value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -129,7 +292,6 @@ public sealed partial class SimpleQueryStringQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.Serverless.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -137,9 +299,7 @@ public sealed partial class SimpleQueryStringQuery /// Query string in the simple query string syntax you wish to parse and use for search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -147,7 +307,6 @@ public sealed partial class SimpleQueryStringQuery /// Suffix appended to quoted text in the query string. /// /// - [JsonInclude, JsonPropertyName("quote_field_suffix")] public string? QuoteFieldSuffix { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query(SimpleQueryStringQuery simpleQueryStringQuery) => Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query.SimpleQueryString(simpleQueryStringQuery); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanQuery.g.cs index b12510520db..e58bc6c6b7b 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal SpanQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SpanQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SpanQuery SpanContaining(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanContainingQuery spanContainingQuery) => new SpanQuery("span_containing", spanContainingQuery); public static SpanQuery SpanFieldMasking(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFieldMaskingQuery spanFieldMaskingQuery) => new SpanQuery("span_field_masking", spanFieldMaskingQuery); @@ -70,147 +75,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SpanQueryConverter : JsonConverter +internal sealed partial class SpanQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SpanQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantSpanContaining = System.Text.Json.JsonEncodedText.Encode("span_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFieldMasking = System.Text.Json.JsonEncodedText.Encode("span_field_masking"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFirst = System.Text.Json.JsonEncodedText.Encode("span_first"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanGap = System.Text.Json.JsonEncodedText.Encode("span_gap"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanMulti = System.Text.Json.JsonEncodedText.Encode("span_multi"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNear = System.Text.Json.JsonEncodedText.Encode("span_near"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNot = System.Text.Json.JsonEncodedText.Encode("span_not"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanOr = System.Text.Json.JsonEncodedText.Encode("span_or"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanTerm = System.Text.Json.JsonEncodedText.Encode("span_term"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanWithin = System.Text.Json.JsonEncodedText.Encode("span_within"); + + public override SpanQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantSpanContaining)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "span_containing") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_gap") + if (reader.ValueTextEquals(VariantSpanGap)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanGap.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_within") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SpanQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SpanQuery(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanQuery { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, SpanQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "span_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFirstQuery)value.Variant, options); - break; - case "span_gap": - JsonSerializer.Serialize>(writer, (KeyValuePair)value.Variant, options); - break; - case "span_multi": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - } + case "": + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanContainingQuery?)value.Variant); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFieldMaskingQuery?)value.Variant); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanFirstQuery?)value.Variant); + break; + case "span_gap": + writer.WriteProperty(options, value.VariantType, (KeyValuePair?)value.Variant); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanMultiTermQuery?)value.Variant); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNearQuery?)value.Variant); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanNotQuery?)value.Variant); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanOrQuery?)value.Variant); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanTermQuery?)value.Variant); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.QueryDsl.SpanWithinQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SpanQuery)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanTermQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanTermQuery.g.cs index 3567a984d2f..1b289af6908 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanTermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SpanTermQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,68 +28,75 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class SpanTermQueryConverter : JsonConverter +internal sealed partial class SpanTermQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SpanTermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override SpanTermQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new SpanTermQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + reader.Read(); + return new SpanTermQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); reader.Read(); - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanTermQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Value = propValue.Value + }; } - public override void Write(Utf8JsonWriter writer, SpanTermQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanTermQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize SpanTermQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); + writer.WritePropertyName(options, value.Field); writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -104,6 +112,10 @@ public SpanTermQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal SpanTermQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs index d0034b94dbb..2bdc8916711 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal SparseVectorQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SparseVectorQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SparseVectorQuery InferenceId(Elastic.Clients.Elasticsearch.Serverless.Id id) => new SparseVectorQuery("inference_id", id); @@ -92,115 +97,89 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SparseVectorQueryConverter : JsonConverter +internal sealed partial class SparseVectorQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SparseVectorQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantInferenceId = System.Text.Json.JsonEncodedText.Encode("inference_id"); - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - Elastic.Clients.Elasticsearch.Serverless.Field fieldValue = default; - string? queryValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override SparseVectorQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propField = default; + LocalJsonProperty propQuery = default; + LocalJsonProperty propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") + if (propBoost.TryRead(ref reader, options, PropBoost)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "field") + if (propField.TryRead(ref reader, options, PropField)) { - fieldValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "query") + if (propQuery.TryRead(ref reader, options, PropQuery)) { - queryValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "inference_id") + if (reader.ValueTextEquals(VariantInferenceId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInferenceId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SparseVectorQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SparseVectorQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Field = fieldValue; - result.Query = queryValue; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SparseVectorQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Field = propField.Value + , + Query = propQuery.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, SparseVectorQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SparseVectorQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.Field is not null) - { - writer.WritePropertyName("field"); - JsonSerializer.Serialize(writer, value.Field, options); - } - - if (!string.IsNullOrEmpty(value.Query)) - { - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "inference_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.Id)value.Variant, options); - break; - } + case "": + break; + case "inference_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.Id?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SparseVectorQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermQuery.g.cs index b5e2dfd6e85..09e7f2870e0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,80 +28,88 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class TermQueryConverter : JsonConverter +internal sealed partial class TermQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override TermQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new TermQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCaseInsensitive = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new TermQuery { Field = propField.Value, Value = result }; + } + catch (System.Text.Json.JsonException) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + throw; } } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); reader.Read(); - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermQuery + { + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Value = propValue.Value + }; } - public override void Write(Utf8JsonWriter writer, TermQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize TermQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); + writer.WritePropertyName(options, value.Field); writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - writer.WritePropertyName("value"); - JsonSerializer.Serialize(writer, value.Value, options); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -116,6 +125,10 @@ public TermQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal TermQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermRangeQuery.g.cs index 538911f2a18..1cb5d884023 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermRangeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,127 +28,115 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class TermRangeQueryConverter : JsonConverter +internal sealed partial class TermRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + + public override TermRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new TermRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propGt = default; + LocalJsonProperty propGte = default; + LocalJsonProperty propLt = default; + LocalJsonProperty propLte = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, TermRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize TermRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gt)) - { - writer.WritePropertyName("gt"); - writer.WriteStringValue(value.Gt); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gte)) - { - writer.WritePropertyName("gte"); - writer.WriteStringValue(value.Gte); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lt)) - { - writer.WritePropertyName("lt"); - writer.WriteStringValue(value.Lt); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lte)) - { - writer.WritePropertyName("lte"); - writer.WriteStringValue(value.Lte); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Relation is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermRangeQuery { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(TermRangeQueryConverter))] -public sealed partial class TermRangeQuery +public sealed partial class TermRangeQuery : IRangeQuery { public TermRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) { @@ -156,6 +145,10 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal TermRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +195,8 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) /// /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "termrangequery"; } public sealed partial class TermRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsQuery.g.cs index ed80e1a50a8..e9b6d74cf7c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,66 +28,55 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class TermsQueryConverter : JsonConverter +internal sealed partial class TermsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override TermsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new TermsQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty propTerms = default; + LocalJsonProperty propBoost = default; + LocalJsonProperty propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Terms = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - return variant; - } - - public override void Write(Utf8JsonWriter writer, TermsQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Terms is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Terms, options); + propField.Initialized = propTerms.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propTerms.Value); } - if (value.Boost.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsQuery { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Terms = propTerms.Value +, + Boost = propBoost.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Terms); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsSetQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsSetQuery.g.cs index 8da1d26d0e4..ee12b8c13a0 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsSetQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/TermsSetQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,104 +28,98 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class TermsSetQueryConverter : JsonConverter +internal sealed partial class TermsSetQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsSetQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatchField = System.Text.Json.JsonEncodedText.Encode("minimum_should_match_field"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatchScript = System.Text.Json.JsonEncodedText.Encode("minimum_should_match_script"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override TermsSetQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new TermsSetQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propMinimumShouldMatch = default; + LocalJsonProperty propMinimumShouldMatchField = default; + LocalJsonProperty propMinimumShouldMatchScript = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match_field") - { - variant.MinimumShouldMatchField = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match_script") - { - variant.MinimumShouldMatchScript = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terms") - { - variant.Terms = JsonSerializer.Deserialize>(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, TermsSetQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize TermsSetQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propMinimumShouldMatchField.TryRead(ref reader, options, PropMinimumShouldMatchField)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propMinimumShouldMatchScript.TryRead(ref reader, options, PropMinimumShouldMatchScript)) + { + continue; + } - if (value.MinimumShouldMatchField is not null) - { - writer.WritePropertyName("minimum_should_match_field"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchField, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.MinimumShouldMatchScript is not null) - { - writer.WritePropertyName("minimum_should_match_script"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchScript, options); - } + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - writer.WritePropertyName("terms"); - JsonSerializer.Serialize(writer, value.Terms, options); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsSetQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + MinimumShouldMatchField = propMinimumShouldMatchField.Value +, + MinimumShouldMatchScript = propMinimumShouldMatchScript.Value +, + QueryName = propQueryName.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsSetQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMinimumShouldMatchField, value.MinimumShouldMatchField); + writer.WriteProperty(options, PropMinimumShouldMatchScript, value.MinimumShouldMatchScript); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropTerms, value.Terms); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +135,10 @@ public TermsSetQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal TermsSetQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs index 443a3d82046..c3d1191bf89 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,60 +28,51 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class UntypedDecayFunctionConverter : JsonConverter +internal sealed partial class UntypedDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override UntypedDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new UntypedDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, UntypedDecayFunction value, JsonSerializerOptions options) + public override UntypedDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; + LocalJsonProperty> propPlacement = default; + LocalJsonProperty propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UntypedDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UntypedDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedDecayFunctionConverter))] -public sealed partial class UntypedDecayFunction +public sealed partial class UntypedDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Serverless.Field Field { get; set; } @@ -91,6 +83,8 @@ public sealed partial class UntypedDecayFunction /// public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.Serverless.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "untypeddecayfunction"; } public sealed partial class UntypedDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs index 3fd405c221e..c673d22e2cc 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -public sealed partial class UntypedDistanceFeatureQuery +public sealed partial class UntypedDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class UntypedDistanceFeatureQuery public object Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "untypeddistancefeaturequery"; } public sealed partial class UntypedDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs index 4a324ee690e..fe7c0716961 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,151 +28,135 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class UntypedRangeQueryConverter : JsonConverter +internal sealed partial class UntypedRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override UntypedRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override UntypedRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new UntypedRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propFormat = default; + LocalJsonProperty propGt = default; + LocalJsonProperty propGte = default; + LocalJsonProperty propLt = default; + LocalJsonProperty propLte = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRelation = default; + LocalJsonProperty propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_zone") - { - variant.TimeZone = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, UntypedRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize UntypedRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.TimeZone)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UntypedRangeQuery { - writer.WritePropertyName("time_zone"); - writer.WriteStringValue(value.TimeZone); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value +, + TimeZone = propTimeZone.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UntypedRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedRangeQueryConverter))] -public sealed partial class UntypedRangeQuery +public sealed partial class UntypedRangeQuery : IRangeQuery { public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) { @@ -180,6 +165,10 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal UntypedRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +229,8 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "untypedrangequery"; } public sealed partial class UntypedRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/WildcardQuery.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/WildcardQuery.g.cs index f45948b7b38..70b141c3de1 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/WildcardQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryDsl/WildcardQuery.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,108 +28,105 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryDsl; -internal sealed partial class WildcardQueryConverter : JsonConverter +internal sealed partial class WildcardQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override WildcardQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + private static readonly System.Text.Json.JsonEncodedText PropWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override WildcardQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.Value = reader.ReadValue(options); + propField.Initialized = true; reader.Read(); - var variant = new WildcardQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new WildcardQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propBoost = default; + LocalJsonProperty propCaseInsensitive = default; + LocalJsonProperty propQueryName = default; + LocalJsonProperty propRewrite = default; + LocalJsonProperty propValue = default; + LocalJsonProperty propWildcard = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "wildcard") - { - variant.Wildcard = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, WildcardQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize WildcardQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + if (propWildcard.TryRead(ref reader, options, PropWildcard)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Value)) - { - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Wildcard)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new WildcardQuery { - writer.WritePropertyName("wildcard"); - writer.WriteStringValue(value.Wildcard); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value +, + Wildcard = propWildcard.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, WildcardQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); + writer.WriteProperty(options, PropWildcard, value.Wildcard); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -144,6 +142,10 @@ public WildcardQuery(Elastic.Clients.Elasticsearch.Serverless.Field field) Field = field; } + internal WildcardQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryRules/QueryRule.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryRules/QueryRule.g.cs index 66166ab9488..d79b772189d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryRules/QueryRule.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryRules/QueryRule.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless.QueryRules; +internal sealed partial class QueryRuleConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropRuleId = System.Text.Json.JsonEncodedText.Encode("rule_id"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override QueryRule Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty propActions = default; + LocalJsonProperty> propCriteria = default; + LocalJsonProperty propPriority = default; + LocalJsonProperty propRuleId = default; + LocalJsonProperty propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propRuleId.TryRead(ref reader, options, PropRuleId)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRule + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + RuleId = propRuleId.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRule value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropRuleId, value.RuleId); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRuleConverter))] public sealed partial class QueryRule { /// @@ -35,7 +110,6 @@ public sealed partial class QueryRule /// The format of this action depends on the rule type. /// /// - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleActions Actions { get; set; } /// @@ -44,10 +118,7 @@ public sealed partial class QueryRule /// If multiple criteria are specified for a rule, all criteria must be met for the rule to be applied. /// /// - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } /// @@ -55,7 +126,6 @@ public sealed partial class QueryRule /// A unique identifier for the rule. /// /// - [JsonInclude, JsonPropertyName("rule_id")] public Elastic.Clients.Elasticsearch.Serverless.Id RuleId { get; set; } /// @@ -65,7 +135,6 @@ public sealed partial class QueryRule /// exclude will exclude specific documents from search results. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Serverless.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryVectorBuilder.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryVectorBuilder.g.cs index 52036aa17c6..02d8407ec88 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryVectorBuilder.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/QueryVectorBuilder.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal QueryVectorBuilder(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal QueryVectorBuilder() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static QueryVectorBuilder TextEmbedding(Elastic.Clients.Elasticsearch.Serverless.TextEmbedding textEmbedding) => new QueryVectorBuilder("text_embedding", textEmbedding); @@ -61,57 +66,44 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class QueryVectorBuilderConverter : JsonConverter +internal sealed partial class QueryVectorBuilderConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryVectorBuilder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override QueryVectorBuilder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantTextEmbedding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "text_embedding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'QueryVectorBuilder' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new QueryVectorBuilder(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryVectorBuilder { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, QueryVectorBuilder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryVectorBuilder value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.TextEmbedding)value.Variant, options); - break; - } + case "": + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.TextEmbedding?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(QueryVectorBuilder)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RRFRetriever.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RRFRetriever.g.cs index 100f1f40cc2..5e48469846d 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RRFRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RRFRetriever.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,80 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class RRFRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropRankConstant = System.Text.Json.JsonEncodedText.Encode("rank_constant"); + private static readonly System.Text.Json.JsonEncodedText PropRankWindowSize = System.Text.Json.JsonEncodedText.Encode("rank_window_size"); + private static readonly System.Text.Json.JsonEncodedText PropRetrievers = System.Text.Json.JsonEncodedText.Encode("retrievers"); + + public override RRFRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propRankConstant = default; + LocalJsonProperty propRankWindowSize = default; + LocalJsonProperty> propRetrievers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propRankConstant.TryRead(ref reader, options, PropRankConstant)) + { + continue; + } + + if (propRankWindowSize.TryRead(ref reader, options, PropRankWindowSize)) + { + continue; + } + + if (propRetrievers.TryRead(ref reader, options, PropRetrievers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RRFRetriever + { + Filter = propFilter.Value +, + MinScore = propMinScore.Value +, + RankConstant = propRankConstant.Value +, + RankWindowSize = propRankWindowSize.Value +, + Retrievers = propRetrievers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RRFRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropRankConstant, value.RankConstant); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize); + writer.WriteProperty(options, PropRetrievers, value.Retrievers); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RRFRetrieverConverter))] public sealed partial class RRFRetriever { /// @@ -34,8 +109,6 @@ public sealed partial class RRFRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +116,6 @@ public sealed partial class RRFRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -51,7 +123,6 @@ public sealed partial class RRFRetriever /// This value determines how much influence documents in individual result sets per query have over the final ranked result set. /// /// - [JsonInclude, JsonPropertyName("rank_constant")] public int? RankConstant { get; set; } /// @@ -59,7 +130,6 @@ public sealed partial class RRFRetriever /// This value determines the size of the individual result sets per query. /// /// - [JsonInclude, JsonPropertyName("rank_window_size")] public int? RankWindowSize { get; set; } /// @@ -67,7 +137,6 @@ public sealed partial class RRFRetriever /// A list of child retrievers to specify which sets of returned top documents will have the RRF formula applied to them. /// /// - [JsonInclude, JsonPropertyName("retrievers")] public ICollection Retrievers { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Retriever(RRFRetriever rRFRetriever) => Elastic.Clients.Elasticsearch.Serverless.Retriever.Rrf(rRFRetriever); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Retriever.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Retriever.g.cs index f6ba60c8271..814948b9836 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Retriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Retriever.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -39,12 +40,16 @@ internal Retriever(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Retriever() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Retriever Knn(Elastic.Clients.Elasticsearch.Serverless.KnnRetriever knnRetriever) => new Retriever("knn", knnRetriever); public static Retriever Rrf(Elastic.Clients.Elasticsearch.Serverless.RRFRetriever rRFRetriever) => new Retriever("rrf", rRFRetriever); @@ -65,97 +70,92 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RetrieverConverter : JsonConverter +internal sealed partial class RetrieverConverter : System.Text.Json.Serialization.JsonConverter { - public override Retriever Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText VariantRrf = System.Text.Json.JsonEncodedText.Encode("rrf"); + private static readonly System.Text.Json.JsonEncodedText VariantRule = System.Text.Json.JsonEncodedText.Encode("rule"); + private static readonly System.Text.Json.JsonEncodedText VariantStandard = System.Text.Json.JsonEncodedText.Encode("standard"); + private static readonly System.Text.Json.JsonEncodedText VariantTextSimilarityReranker = System.Text.Json.JsonEncodedText.Encode("text_similarity_reranker"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Retriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantKnn)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "knn") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rrf") + if (reader.ValueTextEquals(VariantRrf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRrf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "standard") + if (reader.ValueTextEquals(VariantStandard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStandard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_similarity_reranker") + if (reader.ValueTextEquals(VariantTextSimilarityReranker)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextSimilarityReranker.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Retriever' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Retriever(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Retriever { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Retriever value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Retriever value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.KnnRetriever)value.Variant, options); - break; - case "rrf": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.RRFRetriever)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.RuleRetriever)value.Variant, options); - break; - case "standard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.StandardRetriever)value.Variant, options); - break; - case "text_similarity_reranker": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Serverless.TextSimilarityReranker)value.Variant, options); - break; - } + case "": + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.KnnRetriever?)value.Variant); + break; + case "rrf": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.RRFRetriever?)value.Variant); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.RuleRetriever?)value.Variant); + break; + case "standard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.StandardRetriever?)value.Variant); + break; + case "text_similarity_reranker": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Serverless.TextSimilarityReranker?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Retriever)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RuleRetriever.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RuleRetriever.g.cs index d4b7c4c0874..5ddd46235e2 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RuleRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/RuleRetriever.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,90 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class RuleRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMatchCriteria = System.Text.Json.JsonEncodedText.Encode("match_criteria"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropRankWindowSize = System.Text.Json.JsonEncodedText.Encode("rank_window_size"); + private static readonly System.Text.Json.JsonEncodedText PropRetriever = System.Text.Json.JsonEncodedText.Encode("retriever"); + private static readonly System.Text.Json.JsonEncodedText PropRulesetIds = System.Text.Json.JsonEncodedText.Encode("ruleset_ids"); + + public override RuleRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonProperty?> propFilter = default; + LocalJsonProperty propMatchCriteria = default; + LocalJsonProperty propMinScore = default; + LocalJsonProperty propRankWindowSize = default; + LocalJsonProperty propRetriever = default; + LocalJsonProperty> propRulesetIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>))) + { + continue; + } + + if (propMatchCriteria.TryRead(ref reader, options, PropMatchCriteria)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propRankWindowSize.TryRead(ref reader, options, PropRankWindowSize)) + { + continue; + } + + if (propRetriever.TryRead(ref reader, options, PropRetriever)) + { + continue; + } + + if (propRulesetIds.TryRead(ref reader, options, PropRulesetIds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RuleRetriever + { + Filter = propFilter.Value +, + MatchCriteria = propMatchCriteria.Value +, + MinScore = propMinScore.Value +, + RankWindowSize = propRankWindowSize.Value +, + Retriever = propRetriever.Value +, + RulesetIds = propRulesetIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuleRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFilter, value.Filter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query>)); + writer.WriteProperty(options, PropMatchCriteria, value.MatchCriteria); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize); + writer.WriteProperty(options, PropRetriever, value.Retriever); + writer.WriteProperty(options, PropRulesetIds, value.RulesetIds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuleRetrieverConverter))] public sealed partial class RuleRetriever { /// @@ -34,8 +119,6 @@ public sealed partial class RuleRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Serverless.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +126,6 @@ public sealed partial class RuleRetriever /// The match criteria that will determine if a rule in the provided rulesets should be applied. /// /// - [JsonInclude, JsonPropertyName("match_criteria")] public object MatchCriteria { get; set; } /// @@ -51,7 +133,6 @@ public sealed partial class RuleRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -59,7 +140,6 @@ public sealed partial class RuleRetriever /// This value determines the size of the individual result set. /// /// - [JsonInclude, JsonPropertyName("rank_window_size")] public int? RankWindowSize { get; set; } /// @@ -67,7 +147,6 @@ public sealed partial class RuleRetriever /// The retriever whose results rules should be applied to. /// /// - [JsonInclude, JsonPropertyName("retriever")] public Elastic.Clients.Elasticsearch.Serverless.Retriever Retriever { get; set; } /// @@ -75,7 +154,6 @@ public sealed partial class RuleRetriever /// The ruleset IDs containing the rules this retriever is evaluating against. /// /// - [JsonInclude, JsonPropertyName("ruleset_ids")] public ICollection RulesetIds { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Serverless.Retriever(RuleRetriever ruleRetriever) => Elastic.Clients.Elasticsearch.Serverless.Retriever.Rule(ruleRetriever); diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Script.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Script.g.cs index a3b666f40e3..6f1d1687cfd 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Script.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Script.g.cs @@ -18,6 +18,7 @@ #nullable restore using Elastic.Clients.Elasticsearch.Serverless.Fluent; +using Elastic.Clients.Elasticsearch.Serverless.Next; using Elastic.Clients.Elasticsearch.Serverless.Serialization; using System; using System.Collections.Generic; @@ -27,6 +28,86 @@ namespace Elastic.Clients.Elasticsearch.Serverless; +internal sealed partial class ScriptConverter : System.Text.Json.Serialization.JsonConverter